This topic is locked

Required Field

7/19/2008 10:31:33 AM
PHPRunner General questions
B
bobby123 authorDevClub member

Hi All
Hope someone can help me with a problem i have, Not sure just how to code this.
I want to control the Required Field setup on a details table from a field in the master table
If the user enters information in field X in the mater table then, Field Y and Field Z in the details table are set to required fields.
I hope this makes sence
Thanks for any help
Robert

S
swanside 7/19/2008

Hi All

Hope someone can help me with a problem i have, Not sure just how to code this.
I want to control the Required Field setup on a details table from a field in the master table
If the user enters information in field X in the mater table then, Field Y and Field Z in the details table are set to required fields.
I hope this makes sence
Thanks for any help
Robert


In the visual editor you can select that the field is required there.

B
bobby123 authorDevClub member 7/19/2008

Thanks swanside
I am aware that I can select field is required from visual editor, What I am trying to do is If the user enters information in field X in the mater table then, Field Y and Field Z in the details table are set to required fields.

If the user doesn't enters information in field X in the mater table then Field Y and Field Z in the details table is not required
I think I didn't explain to well last time
Thanks

Robert

S
swanside 7/19/2008

Thanks swanside

I am aware that I can select field is required from visual editor, What I am trying to do is If the user enters information in field X in the mater table then, Field Y and Field Z in the details table are set to required fields.

If the user doesn't enters information in field X in the mater table then Field Y and Field Z in the details table is not required
I think I didn't explain to well last time
Thanks

Robert


Sorry, I see what you mean now.

I have seen several topics on here about disabling fields, so I am sure somebody will give you the answer.
Swanny.

J
Jane 7/21/2008

Hi,
use JavaScript to define or undefine required fields:

if(document.forms.editform.value_field1.value=='some value')

define('value_field2','IsRequired','field2: ');

else

undefine('value_field2');
function undefine(n)

{

if (document.editform != null)

{

for (i = 0; i < checkObjects.length; i++)

{

if (checkObjects[i].form.name==n)

checkObjects.splice(i,1);

}

}

}

B
bobby123 authorDevClub member 7/23/2008

Thanks Jane
One question, where to I place the code and how do I reference master table field and detail table fields
Thanks
Robert

J
Jane 7/24/2008

Robert,
you can add this code in HTML mode on the Visual Editor tab. Don't forget to add {literal} and <script> tags around it:

{literal}<script>

...

</script>{/literal}


To check master value join master and detail tables on the Edit SQL query tab and check master field on the add/edit pages on the Choose fields tab.

Then remove this field from update SQL query in the Before record added/updated event:

unset($values["MasterFieldName"]);