Jump to content

Storing module config fails if using fieldsets


apeisa
 Share

Recommended Posts

On upcoming ShoppingCheckout module I have quite few settings options. I thought that I get much nicer UI by providing some fieldsets there. I had quite a few debugging sessions to figure why my values didn't save. After first save they were there, but after you visited module again they were back to defaults.

I have the usual $fields as InputfieldWrapper();

Then this is working code:

 $field = $modules->get("InputfieldText");
 $field->attr('name', 'confirmationUrlSegment');
 $field->attr('value', $data['confirmationUrlSegment']);  
 $field->label = "UrlSegment for confirmation step";
 $field->description = "This is only shown in the url."; 
 $fields->add($field);

But this is non-working code:

 $urls = $modules->get("InputfieldFieldset");
 $urls->label = "Url segments";
 $urls->set('collapsed', Inputfield::collapsedYes);

 $field = $modules->get("InputfieldText");
 $field->attr('name', 'confirmationUrlSegment');
 $field->attr('value', $data['confirmationUrlSegment']);  
 $field->label = "UrlSegment for confirmation step";
 $field->description = "This is only shown in the url."; 
 $urls->add($field);

 $fields->add($urls);

(I have more those UrlSegments, but simplified this with having only one).

The UI and first "save" works nice, but somewhere there is problems that doesn't actually save the values.

Link to comment
Share on other sites

Is this for a getModuleConfigInputfields function? I don't think I've ever tried fieldsets there, though I can't think of any reason why it wouldn't work. But if you don't mind going without fieldsets for a day or two, I can reproduce and fix it here.

Link to comment
Share on other sites

Ryan, thanks for the fix, it works now.. almost. If I have another fieldset later on, it will lose those values. My intended setup is acually like this (without initial wrapper):

FIELDSET
  Textfield
  Textfield
  Textfield
ENDFIELDSET

FIELDSET
  FIELDSET
    Checkbox
    Checkbox
  ENDFIELDSET
  FIELDSET
    Checkbox
    Checkbox
  ENDFIELDSET
ENDFIELDSET

First fieldset saves ok, later ones fail. Next I tried it with this setup:

FIELDSET
  Textfield
  Textfield
  Textfield
ENDFIELDSET

FIELDSET
  Checkbox
  Checkbox
  Checkbox
  Checkbox
ENDFIELDSET

Similar effect: first Fieldset saves ok, other one fails. But when I go this flat:

FIELDSET
  Textfield
  Textfield
  Textfield
ENDFIELDSET

Checkbox
Checkbox
Checkbox
Checkbox

It does save all the values.

Link to comment
Share on other sites

  • 2 years later...

I am not sure how others get around this, but I found out that filters on your renderCheckout() function in ShoppingCheckout.module were not working.

$this->input->urlSegment1 == $this->completedUrlSegment would not return the right values so the function always defaulted to ->renderInformation

Here is how I fixed this part:

	public function renderCheckout()
	{

		if (strstr($this->page->url, 'confirmation')) {
			$out = $this->renderConfirmation();
		}
		else if (strstr($this->page->url, 'payment')) {
			$out = $this->renderPayment();
		}
		else if (strstr($this->page->url, 'completed')) {
			$out = $this->renderCompleted();
		}
		else {
			$out = $this->renderInformation();
			//$out = $this->page->url;
		}

		return $out;
	}

See some other errors connected to the session and clicking the back button on the browser, but I will try to use this :)

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
 Share

  • Recently Browsing   0 members

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