Skip to content

Instantly share code, notes, and snippets.

@MaryOJob
Last active May 13, 2020 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryOJob/211b611810efe95b67329b647ea42af2 to your computer and use it in GitHub Desktop.
Save MaryOJob/211b611810efe95b67329b647ea42af2 to your computer and use it in GitHub Desktop.
Conditional checkbox field example for an existing Register Helper Code
<?php // DO NOT COPY THIS LINE
/**
* Conditional field example. Display two textfields depending on checkbox value
* This can be added to an existing register helper add fields code, if adding this type of field for the first time,
* be sure to check if function exists by adding this: function my_pmprorh_init() { if(!function_exists( "pmprorh_add_registration_field" )) { return false; }
**/
$fields[] = new PMProRH_Field(
'registering_for_pwsn', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => 'Click here if registering for a PWSN' // string for <label></label>
)
);
$fields[] = new PMProRH_Field(
'Name_of_Parent_or_Caregiver', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Name of Parent/Caregiver',
'depends' => array(
array(
'id' => 'registering_for_pwsn', //depends on this field
'value' => true //if checkbox is checked show this field
)
)
)
);
$fields[] = new PMProRH_Field(
'Phone_Number_of_Parent_or_Caregiver', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Phone Number of Parent/Caregiver',
'depends' => array(
array(
'id' => 'registering_for_pwsn', //depends on this field
'value' => true //if checkbox is checked show this field
),
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment