Page 1 of 1

conditional field attribute

PostPosted: Fri Aug 05, 2011 6:52 pm
by Kriss
Hello,
I'm a newbie with Xataface and PHP.
I have a form with two fields FieldA and FieldB.
I would like to change the attribute of FieldB (regex format) depending on the value of the FieldA.
How can i do that ?
Thanks for the response.

Re: conditional field attribute

PostPosted: Sat Aug 06, 2011 5:08 pm
by shannah
If you want to do it on save, then you can use the beforeSave() trigger in the delegate class.
If you want to do it client side you could attach some javascript to your fields.

Re: conditional field attribute

PostPosted: Wed Aug 17, 2011 5:00 am
by Kriss
Hello Shannah,
I tried to install a javascript onchange event handler to a field as you explain in "How to include custom javascripts and stylesheets in your application".
I created an ApplicationDelegate.php file in the directory my_application/conf which contents
function block__custom_javascripts(){
echo '<script src="javascripts.js" type="text/javascript" language="javascript"></script>';
}

But when I refresh the site's page, I got a blank page with function block__custom_javascripts(){ echo ''; } print on the first line.
What's the error I made ?
Thanks

Re: conditional field attribute

PostPosted: Wed Aug 17, 2011 7:10 am
by shannah
The app delegate class needs to be a php class. You are missing the php open tags and the class declaration. Read up on delegate classes and the application delegate class for more details and examples.

Re: conditional field attribute

PostPosted: Thu Aug 25, 2011 9:16 pm
by Kriss
Thank you Steeve for DF and your quick answers.
I succeeded to do a javascript onchange event handler !
I'm less and less a newbie !
But I think, i'll be back later for some news questions.