Changing from content depending on a select list


(David Avery) #21

Hi Nic, 

 

We're on 4.12.0, this is an image of the simple validation rules, and the complex validation rules don't give any condition options either :(

 

vk3uM6x.png

 

I can see how we got our wires a bit crossed now though. This is why I was wondering if there is a way to change the "required" value of the form component through JavaScript. Unfortunately I'm quite new to Squiz and still figuring things out.


(Nic Hubbard) #22

Hi Nic, 

 

We're on 4.12.0, this is an image of the simple validation rules, and the complex validation rules don't give any condition options either :(

 

vk3uM6x.png

 

I can see how we got our wires a bit crossed now though. This is why I was wondering if there is a way to change the "required" value of the form component through JavaScript. Unfortunately I'm quite new to Squiz and still figuring things out.

 

Ah yes, Conditions were not added until 4.14.2. :(


(David Avery) #23

Hey Nic, did you have any good ideas on this topic? I pretty much gave up after finding out our Squiz version was too low for conditions, but I'm now wondering if there would be a way to Change form content dependant on one of the form selects, and not just a select we create in JavaAcript. I can't find any options that would allow me to create a select list and give it options within the HTML.

 

  <select id="options">
    <option value="null">Choose Form</option>
    <option value="t1">Personal details</option>
    <option value="t2">Contact details</option>

  </select>

 

You showed me this, but it's only for pure written html, and not form asset, meaning any option I choose in that HTML coded select list won't pass any information onto the form.

 

This may be a little confusing, so here's a scenario: User clicks on Select list option - Form content appears as required - User submits form - Only the custom form assets are passed and the select list is left without passing any data.

 

If you have any idea, I would very much appreciate the help!

 

Many thanks,

 

Dave 


(David Avery) #24

I think I've found the problem I have. I need to define the id of the selector to be "options", but the default id of the tag is the asset id, and I can't seem to override it by putting id="options" into the 'Extras' section in the details of the asset.

 

Does anyone have any ideas?


(David Avery) #25

Ok, sorted it :D

 

I just did a simple fix which I can't believe I didn't realise... 

 
<script>
$('#options').change(function () {
  var val = $(this).val();
  if (val == 't1') {
    $('#test1').show();
    $('#test2').hide();
  } else if (val == 't2') {
    $('#test1').hide();
    $('#test2').show();
  } else if (val == 'null') {
        $('#test1').hide();
        $('#test2').hide();
    }
});
</script>
 
Changed the #options to #q138219_q10 instead -.-
 
Apologies,
 
Dave

#26

Hey guys I know this thread has been sorted but Nic you said that it’s not a good idea nesting forms into standard pages - so this is no good for caching?

So custom design area or paint layout ? Or would you still be in the same situ with nesting into a paint layout?


I’d love to share with the team what you consider best practice with matrix in regarding forms.



We have hundreds of admins!


(Benjamin Pearson) #27

This is correct, generally forms work best being top level (so no standard page, nested content etc.), and its always better to think in reverse if you want to nest a form in page a, try nesting page a into the form itself. Caching a form will not allow the form to submit properly.


(Nic Hubbard) #28

Hey guys I know this thread has been sorted but Nic you said that it's not a good idea nesting forms into standard pages - so this is no good for caching?
So custom design area or paint layout ? Or would you still be in the same situ with nesting into a paint layout?

 

Yes, like Benjamin said...

 

One thing I have do when a custom form was needed in a sidebar widget was to use an iframe with the custom form inside. Worked pretty well.


#29

Thanks guys I will share the form love