1

I have form element like as follows :

$form['precio'] = array(
  '#type' => 'textfield',
  '#title' => t('Price'),
  '#default_value' => $precio,
  '#size' => 20,
  '#attributes' => array(
    'style'=>'background: none repeat scroll 0 0 #EAEAEA;'
  ),
  '#description' => t('Change the price'),
);

how i add more style attributes to 'precio' ?

2
  • Why don't you add a class or id and do the rest in css?
    – GwenM
    Feb 8, 2016 at 16:02
  • 1
    if this works: 'style'=>'background: none repeat scroll 0 0 #EAEAEA;' then surely this will also work: 'style'=>'background: none repeat scroll 0 0 #EAEAEA;color:black;' Feb 8, 2016 at 17:24

1 Answer 1

2

You can nest the style attributes as follows :

$form['precio'] = array(
  '#type' => 'textfield',
  '#title' => t('Price'),
  '#default_value' => $precio,
  '#size' => 20,
  '#attributes' => array(
    'style'=>'background: none repeat scroll 0 0 #EAEAEA;
              margin: 0 3 4;
              color:red;'
  ),
  '#description' => t('Change the price'),
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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