Add DOB to register PHP file
So I have succesfully added additional fields to the registerapproval.php file that I copied and edited for use in a plugin. Similar to the BotStop Plugin. These additional fields are being saved to the database, under their own column under User.
I am struggling with one last element of the registration form however.
I wish to add a Date Of Birth field so that the applicant can insert their DOB. for the Database the date needs to be in YYYY-MM-DD format, but i do not wish to ask someone to type it in this way.
I would like for them to enter it in the DD-MM-YYYY format, then have code convert it to the correct format.
I know this can be done with this PHP code
$date = DateTime::createFromFormat('d/m/Y H:i:s', $yourDateString); $dateToBeInserted = $date->format('Y-m-d H:i:s');
But how do I ensure this new variable
$dateToBeInserted is added into the database column
I know how to add a field in general such as
<li> <?php echo $this->Form->Label('Why do you want to join CV? (Please add any information you think will support your application)', 'DiscoveryText'); echo $this->Form->TextBox('DiscoveryText', array('MultiLine' => TRUE)); ?> </li>
which I copied and modified to
<li> <?php echo $this->Form->Label('How did you find out about The Chaos Vanguard?', 'findOut'); echo $this->Form->TextBox('findOut', array('MultiLine' => TRUE)); ?> </li>
But how do I do this with the date of birth whilst making sure the format is converted correctly?