Jump to content

Form\Stack doesn't work with \Form\Member


LaCollision

Recommended Posts

Posted

Hi,

I'm pulling my hair out trying to construct a form Stack with \Helpers\Form\Member fields...

new \IPS\Helpers\Form\Stack('mystack', array(), false, array('stackFieldType' => '\IPS\Helpers\Form\Member', 'maxItems' => 20));

 

When adding a new stack row, it looks like several Member autocomplete fields are added in a same field:

46310332_Capturedcran2019-01-0219_18_18.png.16f265cc023fcaf51d6c8b4fa1a67050.png

 

Apparently, the javascript in ips.ui.stack.js doesn't manage to handle the situation.

Am I doing something wrong, or the Stack simply doesn't work with Member fields?

Or is it a bug?

Thank you!

Posted
9 minutes ago, Aiwa said:

Why not just use a member field that allows multiple entries? 

What's the use case for a stack?

 

I'd like to create a team of members: each member would have a role in the team.

So, actually, the Stack would be used with a KeyValue field type, like the \core\Form\SocialProfiles field type. Except that I would use a \Form\Member field type inside, instead of a simple URL field type 🙂 

A team would be something like that:

team.thumb.png.5af8fd5a810ff3ab55b98f491134bfbd.png

 

=> Several members, with a role for each.

I'd like the first field to be a Member field with an autocomplete… 😭

Posted
13 hours ago, Aiwa said:

Have you tried using Matrix instead? 

 

Thanks for the idea!

But unfortunately, adding Member fields in a Matrix looks very very buggy 😭

912548589_Capturedcran2019-01-0310_20_16.thumb.png.763d39eac801d9a30e7d5a756b12ad36.png

Posted
1 minute ago, Aiwa said:

Mind showing your code to build the form? 

 

Something really simple, like:

$matrix = new \IPS\Helpers\Form\Matrix;

$matrix->columns = array(
	'member'		=> function($key, $value, $data)
	{
		return new \IPS\Helpers\Form\Member($key, $value, false, array());
	},
);

$form->addMatrix('members', $matrix);

 

But I'm new to the Matrix, so 😅

 

100.gif

Posted

What you've got is right, not working for me either... Swapped out a Text field for a Member field on an existing app I wrote, I get the same result as you.

592805172_0103h0147y53wa.thumb.png.c02d59ca69870cb61a51068e84269640.png

I'd submit a ticket and report this as a bug.  While you might catch a little grief from T1 since it's 3rd party app related, it's something IPS devs need to hear about.

Posted
16 minutes ago, Aiwa said:

What you've got is right, not working for me either... Swapped out a Text field for a Member field on an existing app I wrote, I get the same result as you.

 

Thank you for having taken the time to look into it 🙂

That's funny, my need is exactly the same as yours: giving a member a role (like Administrators in your screenshot).

In your current form, in the member name field (the 1st field in your columns), you need to type the exact name of the chosen member to make it work?

 

16 minutes ago, Aiwa said:

I'd submit a ticket and report this as a bug.  While you might catch a little grief from T1 since it's 3rd party app related, it's something IPS devs need to hear about.

 

Yes, I just opened one. Thanks! 

Posted
8 hours ago, LaCollision said:

In your current form, in the member name field (the 1st field in your columns), you need to type the exact name of the chosen member to make it work?

The first column is text, won't contain a member name. It's used to match a string from an external system (that is a source of truth) and assign a member group based on that admin controlled string. 

I didn't do much testing when it was a member field to see if the auto complete worked. 

Posted
2 minutes ago, HeadStand said:

Stack doesn't work with any form field that requires javascript. You can't stack a node field either.

This topic gave me an idea of using a matrix in a popuptemplate, yeah... Matrix has the same problems when it requires javascript. It'll render the initial form, but the add button doesn't add rows, it redirects.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...