Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

UserForms problem?


Reply


6 Posts   602 Views

Avatar
Lemonie

Community Member, 70 Posts

24 May 2012 at 11:56am

Edited: 25/05/2012 5:56am

I have created a form and included rules. Currently all the options are shown when the form is submitted even though they are blank and the user has never seen them from their selection. How can I stop this?

Also I would like to process the data. So each time a record is entered with a reference number it goes to that separate record.

Can somebody point me in the right direction .. please???

Edited from: Is there a way to just show fields that have been filled in in the submitted section of the site. I have a form with rules and only want the relevant questions which have been answered shown?

Avatar
Silverfish

Community Member, 59 Posts

24 May 2012 at 9:08pm

Sure.

On creating the form you could just check for each field if there's a value for it and the decide wether to create / display this field or not.

Regards
SF

Avatar
Lemonie

Community Member, 70 Posts

25 May 2012 at 12:12am

Am a bit confused as am a newbie. I have all the fields with rules to hide and show on the actual form. It is on the submission that it is showing lots of blank fields. Am not sure how to do what you are explaining?

Avatar
Lemonie

Community Member, 70 Posts

25 May 2012 at 9:13pm

OK .. I have found some code which I think does what I want ...

*********

$(function()
{
$("form").submit(function()
{
$(this).children(':input[value=""]').attr("disabled", "disabled");

return true; // ensure form still submits
}
});

*************

$(':input').removeAttr("disabled");

I have absolutely no idea where to put this code or if it is suitable? Please would somebody help?!

Avatar
Lemonie

Community Member, 70 Posts

26 May 2012 at 7:56am

If there is no way of omitting the blank fields then why offer dependant forms? Really struggling here.

Avatar
Willr

Forum Moderator, 5513 Posts

26 May 2012 at 8:01pm

Basically this is quite difficult, the visibile of the form field is handled in the front end and the form submission in the backend. The state of a field (visible vs hidden) isn't passed (if you have JS disabled, all the fields will be shown by default)