Forums

How to get article title on input text field?

theupendra 27 Jul, 2015
Is there any way that I can get Article Title on input text field? I want the article title automatically inserted into input field upon loading the Chronoform module.
Thank you!
theupendra 28 Jul, 2015
Hi Bob,
Thanks for the reply.
I do not want hidden field, I want input type text but with Label positioned to the left side as on other form inputs. When the form loads I want to display article title inside the input field automatically.
GreyHead 28 Jul, 2015
Hi theupendra,

Then basically you need to change the 'type' of the input. You could do this by using a Custom Code element as in the FAQ but a slightly neater way is to use a Custom Code action to get the title. Drag a Custom Coe action into the On Load event of your form and move it up above the HTML (Render Form) action. Add the PHP part of the code from the FAQ but save the result to the $form->data[''] array e.g.
<?php
$article_title = '';
$id = \JRequest::getInt('id', '');
$article = \JTable::getInstance('content');
$article->load($id);
$form->data['article_title'] = $article->get('title');
?>
Then give your input the name article_title.
Bob
This topic is locked and no more replies can be posted.