What do you mean by "forms"?
I was working on Drupal the last 8 monthes. One thing i like very much in Drupal is the possibility to manipulate easily any forms from anymodule; adding or deleting elements , adding validations fonctions or submit fonctions. For example it’s very easy to add a field to the user_register form, using the function form_alter to add a field and a hook to register the data collected in the database.
Is this possible to do this kind of thing with the api of modx Revolution ? If yes, can you give me a link to a documentation for this point?
More generally, is there an API dedicated to the forms or are they in html?
Or to take another example : suppose i want to change the value of the submit button from the loggin form; how can i do that without hacking the core?The manager login form?
<form action = "talatatsouin"> <input type = "submit" name = "bill" value = "click if you dare"/> </form>
$form['bill'] = array( '#type' => 'submit', '#value' => 'click if you dare' );
function mymodule_form_alter($form_id, &$form){
if($form_id == 'user_register'){
$form['submit'] = array(
'#type' => 'checkbox',
'#options' => array('Have you read the legal mentions?'),
'#required' => TRUE
}
}
All forms in the front-end, unless you’re using eForm, are most likely done by straight HTML. So you can write forms as you want them to look. I’m not sure what you’re asking, or if you understand the basic Templating principles of MODx.
Yes, for the front-end mainly (but i’m acutally talking about all forms generated by Modx Revolution). Is it possible to change in this way a form in front end provided by a snippet (or a plug-in, don’t know exactly what can do a plug-in in Modx Revolution) ? If yes, can i do this with a plug-in or something else ?
<?php
// Imagine for exemple that you want to add on the register form a button with a choice yes or no to ask the user if
// he has read the condition of utilisation of the site.
// Here is at what it looks like.
if($form_id == 'user_register'){
$form['ma_checkbox'] = array(
'#title' => "Avez vous lu les conditions générales d'utilisation du site ?",
'#type' => 'radios',
'#required' => TRUE,
'#options' => array('oui', 'non');
)
}
return $form;
?>