
Как управлять полями формы комментариев в Drupal 8
22 января 2018 г. 00:02
function sizin_form_comment_form_alter(&$form, &$form_state)
{
$form['author']['name']['#attributes']['placeholder'] = t( 'Name' );
$form['author']['name']['#title']= FALSE; //Subject $form['your_comment']['subject'] = $form['subject'];
$form['your_comment']['subject']['#title'] = FALSE;
$form['your_comment']['subject']['#attributes'] = array('placeholder' => t('title'));
unset($form['subject']);
$form['your_comment']['subject']['#weight'] = -10; //Comment
$form['your_comment']['comment_body'] = $form['comment_body'];
$form['your_comment']['comment_body'][LANGUAGE_NONE][0]['value']['#attributes'] = array('placeholder' => t('comment')); unset($form['comment_body']);
}
function sizin_form_comment_form_alter(&$form, &$form_state)
{
$form['author']['name']['#attributes']['placeholder'] = t( 'Name' );
$form['author']['name']['#title']= FALSE; //Subject $form['your_comment']['subject'] = $form['subject'];
$form['your_comment']['subject']['#title'] = FALSE;
$form['your_comment']['subject']['#attributes'] = array('placeholder' => t('title'));
unset($form['subject']);
$form['your_comment']['subject']['#weight'] = -10; //Comment
$form['your_comment']['comment_body'] = $form['comment_body'];
$form['your_comment']['comment_body'][LANGUAGE_NONE][0]['value']['#attributes'] = array('placeholder' => t('comment')); unset($form['comment_body']);
}
function ws_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
if ($form_id == 'user_login_form' )
{
// Add placeholders.
$form['name']['#attributes']['placeholder'] = t('Имя пользователя...');
$form['pass']['#attributes']['placeholder'] = t('Пароль...');
$form['#attributes']['class'][] = "login-form";
$form['actions']['submit']['#attributes']['class'][] = "btn";
$form['name']['#attributes']['class'][] = "form-control";
$form['pass']['#attributes']['class'][] = "form-control";
$form['name']['#title'] = 'Введите имя';
$form['pass']['#title'] = 'Введите пароль';
unset($form['name']['#description']);
unset($form['pass']['#description']);
// $form['name']['#prefix'] = '<div class="form-group">';
// $form['name']['#suffix'] = '</div>';
}
}
function ss2_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
if ($form_id == 'search_block_form' )
{
$form['actions']['submit']['#attributes']['class'][] = "search-form_submit";
$form['actions']['submit']['#attributes']['class'][] = "fa-search";
$form['actions']['submit']['#value'] = "";
$form['keys']['#attributes']['class'][] = "search-form_input";
}
if ($form_id == 'contact_message_hotite_takoi_ze__form' )
{
$form['actions']['preview']['#access'] = FALSE;
$form['#attributes']['class'][] = "contact-form";
$form['actions']['submit']['#attributes']['class'][] = "btn";
$form['actions']['submit']['#attributes']['class'][] = "btn-primary";
$form['actions']['submit']['#value'] = "отправить заявку";
}
if ($form_id == 'comment_comment_form' )
{
$form['#attributes']['class'][] = "contact-form";
$form['actions']['submit']['#attributes']['class'][] = "btn";
$form['actions']['submit']['#attributes']['class'][] = "btn-primary";
$form['actions']['submit']['#value'] = "отправить комментарий";
$form['author']['name']['#attributes']['placeholder'] = 'Ваше имя';
$form['author']['name']['#title']= FALSE;
}
}