1

I'd like to modify the html of a form field from hook_form_alter(). Any hook for this one? enter image description here

3
  • 1
    Yes, that would be hook_form_alter(), as you've said. If you're having trouble implementing hook_form_alter(), it's very important that you edit the question to include your code, and describe exactly what isn't working. We can't write it for you, as I'm sure you know. Thanks – Clive Nov 28 '13 at 13:35
  • yes but in practice how do I change it? I've uploaded a screenshot of the structure. The issue us how to overwrite the field_multiple_value_form. When I tried to add another function at #theme the page was not respoding – Potney Switters Nov 28 '13 at 13:39
  • 1
    See the answers to this question for a couple of different methods. – Clive Nov 28 '13 at 13:42
2

Your question itself the answer, inside hook_form_alter use the following

$form['field_job']['und'][0]['#prefix'] = 'yours html'

and $form['field_job']['und'][0]['#suffix']='yours close tags of html' this html will wrap field.

1

you just need implement hook_form_alter in your custom field and according drupal form api change what you want :

notice "&" before $from(call by refrence)

get your form id by view source of you page and search form <from .... id="your-form-name" ..../>

function youmoudle_form_alter(&$form,$form_state,$form_id){

if($form_id=="your_form_name"){
// your change come here
}
}
4
  • I am using form alter. That's where I fetched the dpm() posted above. My issue is how to change a specific field. – Potney Switters Nov 28 '13 at 14:30
  • @PotneySwitters what field you want to change ? – Yuseferi Nov 28 '13 at 23:10
  • @PotneySwitters , ok , it seems you edit the question and determined which field you like to change. – Yuseferi Nov 28 '13 at 23:11
  • job_field. But any field would do :) – Potney Switters Nov 29 '13 at 12:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.