Jump to content

InputfieldChosenSelect


LostKobrakai

Recommended Posts

HI,

I am trying to use the Inputfield Chosen Select Multiple in a page reference field that is used in a repeater
and when I add a new items to the repeater the multiple select is not rendered, it only shows a multiple select box.

I think that the javascript code that renders the field is not triggered after the Ajax load
because when turning off the Ajax functionality.

Is there a way to make it possible to render the field in a repeater?

 

Thank you

Link to comment
Share on other sites

I just forked the module and added support for repeaters (only on the multi select inputfield for now); it basically involves 2 steps - changing the module code to use mostly the renderReady method instead of render(), and then some small update to the js file to init the field on the necessary events, which for the sake of brevity also involves moving the init code into its own function var... I submitted a pull request; in the meantime if you need this to work now, you can try the forked version  https://github.com/outflux3/InputfieldChosenSelect

  • Like 4
Link to comment
Share on other sites

  • 3 months later...

Hi,

Do someone know a way to use ChosenSelect in form builder to use pages? A hook maybe?      

I just have the option to type manually text, and however I want pages (as we can use in backend).

Thanks

Mel

Sélection_213.png

Link to comment
Share on other sites

10 hours ago, mel47 said:

Do someone know a way to use ChosenSelect in form builder to use pages? A hook maybe?      

I just have the option to type manually text, and however I want pages (as we can use in backend).

you just have to use a regular multi select, and then init that with the chosen JS on your form; In other words you wouldn't setup the formbuilder field to use chosen select, you would setup a page select multiple with a InputfieldSelectMultiple as the input; then you would config add the chosen assets from within your formbuilder.inc file in your templates folder, using either a conditional or a switch statement; you would also need to add a init js file that would init the inputfield.. (see https://harvesthq.github.io/chosen/ for examples)

  • Like 3
Link to comment
Share on other sites

On 19/12/2017 at 10:49 AM, Macrura said:

you just have to use a regular multi select, and then init that with the chosen JS on your form; In other words you wouldn't setup the formbuilder field to use chosen select, you would setup a page select multiple with a InputfieldSelectMultiple as the input; then you would config add the chosen assets from within your formbuilder.inc file in your templates folder, using either a conditional or a switch statement; you would also need to add a init js file that would init the inputfield.. (see https://harvesthq.github.io/chosen/ for examples)

ok thanks. I will examine this later as it not so "out-of-box" solution. :-)

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...
  • 1 month later...
On 12/19/2017 at 4:49 PM, Macrura said:

you just have to use a regular multi select, and then init that with the chosen JS on your form; In other words you wouldn't setup the formbuilder field to use chosen select, you would setup a page select multiple with a InputfieldSelectMultiple as the input; then you would config add the chosen assets from within your formbuilder.inc file in your templates folder, using either a conditional or a switch statement; you would also need to add a init js file that would init the inputfield.. (see https://harvesthq.github.io/chosen/ for examples)

@Macrura, I do not understand how to configure the assets from within my formbuilder.inc file in my templates folder and how to add a init js file that would init the inputfield.

Can you provide some more detailed guidelines to use ChosenSelect in FormBuilder to use pages?

BTW/Note: I'm using ProcessWire 3.0.98 

Link to comment
Share on other sites

@LAPS

form-builder.inc:

/**
 *
 * Add custom scripts to the form.
 *
 */
$forms->addHookBefore('FormBuilder::render', function($event) {
	$form = $event->arguments(0);
	$config = wire('config');

	switch ($form->name) {
		case 'name-of-form':
			$config->scripts->add($config->urls->templates . "libraries/chosen/name-of-js.js");
			$config->styles->add($config->urls->templates . "libraries/chosen/name-of-css.css");

			$config->scripts->add($config->urls->templates . "FormBuilder/custom-js-init-file.js");

			break;
		// other forms can be added below...
	}

});

in your init file:

    $("#Inputfield_name_of_input").chosen({
        no_results_text: "The planet exists not",
        allow_single_deselect: true,
        width: '100%'
    });

 

  • Like 3
Link to comment
Share on other sites

  • 2 years later...

There is a setting for page fields to allow for pages to be added through it. Iirc in core inputfields this is a completely separate input below the actual page selection. This needs to be enabled for this module to be able to add new pages, as it's using the built in input, but just hides it and allows you to add new pages inline.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...