i am creating a form with cakephp2 and bootstrap everything is working fine but im stuck in little confusion and i cant fix this kindly any bootstrap or cake expert help me thanks,
Check this envelop its stretching upwards
here is my code
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-envelope"></span>
</span>
<?php echo $this->Form->input('email',
array(
'class' => 'form-control',
'type' => 'email',
'placeholder' => 'Enter Email'
)
); ?>
</div>
<!--<input type="email" class="form-control" id="email" placeholder="Enter email" required="required" /></div>-->
</div>
Pass the argument 'label' => false will prevent to display the label
Use
<?php echo $this->Form->input('email',
array(
'class' => 'form-control',
'type' => 'email',
'placeholder' => 'Enter Email',
'label' => false
)
); ?>
You should use label false in your code.
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-envelope"></span>
</span>
<?php echo $this->Form->input('email',
array(
'class' => 'form-control',
'type' => 'email',
'label'=>false,
'placeholder' => 'Enter Email'
)
); ?>
</div>
<!--<input type="email" class="form-control" id="email" placeholder="Enter email" required="required" /></div>-->
</div>
Related
form created by form builder
<form name="post" method="post">
<div id="post">
<div class="form-group">
<input type="text" id="post_title" name="post[title]" required="required" class="form-control"/>
</div>
<div class="form-group">
<textarea id="post_content" name="post[content]" required="required" class="form-control"></textarea>
</div>
<div>
<button type="submit" id="post_postAdd" name="post[postAdd]" class="form-control btn-primary">Create</button>
</div>
<input type="hidden" id="post__token" name="post[_token]" value="ab35508c9.6MnqGe6WDVVVtkdRga_Ahtt5kDssuXri3JBx4HcVdOw.gKCQYdugYSw2_x88wN2y6Z5P_mtJyxaqm95GhkRDP52qoYFjucJOGyTuIA" />
</div>
</form>
i want this. How i create parent (div) elements one or more like below with form builder. Not in twig.
<div class="oneMore"> <!-- I need this element -->
<div class="iWantToAddThis"> <!-- I need this element -->
<div class="form-group">
...input...
</div>
<div class="form-group">
...input...
</div>
</div>
</div>
PostType.php. I created form like below.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class, [
'attr' => [
'class' => 'form-control'
],
'row_attr' => [
'class' => 'form-group'
]
])
->add('content',TextareaType::class, [
'attr' => [
'class' => 'form-control'
],
'row_attr' => [
'class' => 'form-group'
]
])
->add('postAdd', SubmitType::class, [
'attr' => [
'class' => 'form-control btn-primary'
]
]);
}
_form.html.twig (I don't want to add anything in twig)
{{ form(form) }}
I use this hook:
add_action( 'woocommerce_after_checkout_billing_form', 'add_custom_field' );
function add_custom_field( $checkout ) {
echo '<div id="custom_field_wrapper">';
woocommerce_form_field( 'custom_field', array(
'type' => 'text',
'class' => array('custom_field_class'),
'label' => __('Custom Field'),
'placeholder' => __('Please input value ...'),
'required' => false, ),
$checkout->get_value( 'custom_field' ) );
echo '</div>';
}
and i get this markup:
<div id="custom_field_wrapper">
<p class="form-row custom_field_class" id="custom_field_field" data-priority="">
<label for="custom_field" class="">Custom Field</label>
<input type="text" class="input-text " name="custom_field" id="custom_field" placeholder="Please input value ..." value="">
</p>
</div>
But the required markup looks like this:
<div class="row order-form__row">
<div class="col-lg-3 col-md-4">
<label class="label" for="index-field">Индекс:</label>
</div>
<div class="col-lg-6 col-md-6">
<input class="input" type="text" name="index" id="index-field"/>
</div>
<div class="col-lg-3 col-md-2"><a class="field-after" href="javascript:void(0);" target="_blank">Забыли индекс?</a></div>
</div>
Kind smart people help solve the dilemma ... How to change the html markup according to the requirements?
Is there a way to change the html output from wp_login_form(), so that is like the bootstrap form?
The wp_login_form looks like this:
<form class="form-grey" name="loginform" id="loginform" action="http://domain.loc/wp-login.php" method="post">
<p class="login-username">
<label for="user_login">Username</label>
<input type="text" name="log" id="user_login" class="input" value="" size="20">
</p>
<p class="login-password">
<label for="user_pass">Password</label>
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20">
</p>
<p class="login-remember"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever"> Remember Me</label></p>
<p class="login-submit">
<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In">
<input type="hidden" name="redirect_to" value="http://domain.loc/">
</p>
</form>
And Bootstrap Forms look like this:
<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail3">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword3">Password</label>
<input type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
<button type="submit" class="btn btn-default">Sign in</button>
</form>
Try to use this :
Take your arguments as per the classes and IDs required :
$args = array(
'echo' => true,
'redirect' => property_list(),
'form_id' => 'loginform',
'label_username' => '',
'label_password' => '',
'label_remember' => __('Keep me logged in'),
'label_log_in' => __('SIGN IN'),
'id_username' => 'user_login',
'id_password' => 'user_pass',
'id_remember' => 'rememberme',
'id_submit' => 'wp-submit',
'remember' => true,
'value_username' => NULL,
'value_remember' => false
);
Now pass this $args array to function below :
<?php wp_login_form_custom($args);?>
Now you can use this function as defined below :
function wp_login_form_custom($args = array()) {
//you can use the values as $args['form_id'] and so on
//create you own HTML here with classes and IDs defined in the $args
}
I have navigation header like this:
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="search">
<div class="form-group has-feedback">
<input id="searchbox" type="text" placeholder="Search" class="form-control">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>
I have problem when I want to convert this code using yii\bootstrap\NavBar;:
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="search">
<div class="form-group has-feedback">
<input id="searchbox" type="text" placeholder="Search" class="form-control">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
</form>
</div><!--/.navbar-collapse -->
And this is the code of my Layout using yii\bootstrap\NavBar;:
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-inverse navbar-fixed-top',
'role' => 'navigation',
],
]);
NavBar::end();
?>
I have been read Navbar Widget, but still don't understand. Is there anyone who can teach me to using Navbar widget on Yii2 framework?.
Ok here is the code for that,here i am just placing the searchbox from exactly what you posted in question and i am guessing that you know how to echo other menu links in navbar
Anyway it goes like this
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-inverse navbar-fixed-top',
'role' => 'navigation',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['controller url here']],
];
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
echo "<form class='navbar-form navbar-right' role='search'>
<div class='form-group has-feedback'>
<input id='searchbox' type='text' placeholder='Search' class='form-control'>
<span id='searchicon' class='fa fa-search form-control-feedback'></span>
</div>
</form>";
NavBar::end();
?>
I'm trying to add attributes to my rendered radios
$builder
->add('myRadios', 'choice', array(
'choices' => array(
'one' => 'uno',
'two' => 'due'),
'multiple' => false,
'attr' => array('class' => 'testClass'),
'expanded' => true
the output is:
<div class="control-group">
<label class="control-label required">Myradios</label>
<div class="controls">
<label for="form_one_0" class="required radio">
<input type="radio" id="form_one_0" name="form[one]" required="required" value="uno" />
<span>Uno</span>
</label>
<label for="form_two_1" class="required radio">
<input type="radio" id="form_two_1" name="form[two]" required="required" value="due" />
<span>Due</span>
</label>
</div>
</div>
no references to class='testClass'
I can't find any issue online
Try this way Adam,
$form = $app['form.factory']->createBuilder('form')
->add('myRadios', 'choice', array(
'choices' => array(
'one' => 'uno',
'two' => 'due'),
'multiple' => false,
'expanded' => true,
'attr' => array('class' => 'testClass'),
))
->getForm();
it works:
<div id="form_myRadios" class="testClass">
<input type="radio" id="form_myRadios_0" name="form[myRadios]" required="required" value="one">
<label for="form_myRadios_0" class="required">uno</label>
<input type="radio" id="form_myRadios_1" name="form[myRadios]" required="required" value="two">
<label for="form_myRadios_1" class="required">due</label>
</div>
How does your twig code look like? And which form template do you use?
You use a custom form template because
<div class="control-group">
<label class="control-label required">Myradios</label>
<div class="controls">
is definitely not standard Symfony!