i use TYPO3 7.6.10
i use indexed_search 7.6.0
when i submit form i go to the target page and i get the results.
The url of target page is:
search.html?tx_indexedsearch_pi2%5Baction%5D=search&tx_indexedsearch_pi2%5Bcontroller%5D=Search
i want to remove action and controller variable form url to get:
search.html
i can do that adding a configuration to real url like this:
'searchConfiguration' => array(
array(
'GETvar' => 'tx_indexedsearch_pi2[action]',
'valueMap' => array(),
'noMatch' => 'bypass'
),
array(
'GETvar' => 'tx_indexedsearch_pi2[controller]',
'valueMap' => array(),
'noMatch' => 'bypass'
)),'135' => 'searchConfiguration'
Now i get a nice url but the submitted data is not sent!
How can i resolve it?
Those parameters are required for the controller to be routed by the request. Without them the sWord will not become processed by the controller and you will not get any results.
Instead of bypassing them you can rewrite them to get something like /search/perform/results/ or you can configure your form to use method="POST" instead of "GET" and add those parameters above into hidden fields of the form and make sure the form attribute does not have the arguments as parameters in the action. Example form in the result:
<form method="POST" class="header-search-form hidden-xs hidden-sm" action="suche.html">
<input type="hidden" name="tx_indexedsearch_pi2[controller]" value="Search">
<input type="hidden" name="tx_indexedsearch_pi2[action]" value="search">
<div class="input-group">
<input type="text" class="search-query form-control" placeholder="Suchen" id="default-search-input" name="tx_indexedsearch_pi2[search][sword]">
<span class="input-group-btn">
<button class="btn" type="button">
<i class="fa fa-search" aria-hidden="true"></i>
</button>
</span>
</div>
</form>
Related
I set the form parameters:
<?
$form = ActiveForm::begin([
'id' => 'activeForm',
'action' => 'javascript://',
]);
$checkboxTemplate = '<div class="checkbox">{labelTitle}{beginLabel}{input}<span class="slider round"></span>{endLabel}{error}{hint}</div>';
echo $form->field($aclForm, tbl_RbacActions::IS_DEVELOPMENT)
->checkbox([
'labelOptions' => ['class' => 'switch'],
'template' => $checkboxTemplate
]);
?>
As a result, it still turns a standard form with standart classes:
<form id="Index-form" class="row col-12 no-gutters" action="javascript://" method="post">
<input type="hidden" name="_csrf-frontend" value="Lo7lVHTJ9wcN5rdfjK-b7AgW8L4OHEaqI9IsVofZPOl3yKkFBJqAQz-i-y7H3-mdMUmY-H1RcMRBhkU01-F2oA==">
<div class="form-group field-aclform-is_development required">
<input type="hidden" name="AclForm[is_development]" value="0">
<label class="switch">
<input type="checkbox" id="aclform-is_development" name="AclForm[is_development]" value="1" template="{input}{beginLabel}{labelTitle}{endLabel}{error}"> Is Development</label>
<div class="help-block"></div>
</div>
</form>
Why is it adding the template as the input attribute?
You haven't provided the HTML template that you are trying to follow or integrate here in the checkbox, but regarding the template being added as the attribute of the input field is quite logical as you are passing it as the option of the checkbox rather than the field option.
You need to provide the template as an array to the third parameter option of the field see below
<?php
$form = ActiveForm::begin(
[
'id' => 'activeForm',
'action' => 'javascript://'
]
);
$checkboxTemplate = '<div class="checkbox">{labelTitle}{beginLabel}{input}<span class="slider round"></span>{endLabel}{error}{hint}</div>';
echo $form->field(
$aclForm,
tbl_RbacActions::IS_DEVELOPMENT,
[
'template' => $checkboxTemplate
]
)->checkbox(
[
'labelOptions' => ['class' => 'switch']
]
);
The Bootstrap Example Code
http://getbootstrap.com/css/#forms
Copying a simple email input element from getbootstrap.com suggests we format the HTML in the following way:
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input id="exampleInputEmail1" class="form-control" type="email" placeholder="Email">
</div>
Above we have a <label> tag that closes straight after it's text content, "Email address".
I would now like to create the same form group using Zend Framework.
module/MyApp/src/MyModule/Form/MyForm.php
namespace MyModule\Form;
use Zend\Form\Form;
class MyModuleForm extends Form {
public function __construct($name = null)
{
$this->add(array(
'name' => 'email_address',
'type' => 'Email',
'options' => array(
'label' => 'Email address',
),
'attributes' => array(
'class' => 'form-control',
'placeholder' => 'Email'
)
));
The Zend Framework generated code
<div class="form-group">
<label>
<span>Email address</span>
<input class="form-control" type="email" placeholder="Email" id="exampleInputEmail1">
</label>
</div>
In the above HTML you can see that Zend has not closed the <label> tag. Instead the <label> ecapsulates its children.
How do I change the way the Zend rendering works?
I assume you are using ZF2 FormRow view helper to render your form element in your view script, e.g. $this->formRow($this->form->get('email_address'));
To render it differently you need to use the following view helpers
FormLabel
FormText
FormElementErrors
If for example you wanted to render as a definition list you would use something like
<dl class="zend_form">
<dt><?php echo $this->formLabel($this->form->get('email_address')); ?></dt>
<dd><?php echo $this->formText($this->form->get('email_address')); ?>
<?php echo $this->formElementErrors($this->form->get('email_address')); ?></dd>
</dl>
I hope this points you in the right direction
Here the code for checkbox generation
//code
echo $this->Form->select('Model.field', $options, array(
'multiple' => 'checkbox','div'=>'col-md-9',
'class' => 'required'
));
//output
<div class="required" aria-required="true">
<input type="checkbox" id="FormData6783" value="83" name="data[Model][field][]">
<label for="FormData6783">Sr. Secondary</label>
</div>
<div class="required" aria-required="true">
<input type="checkbox" id="FormData6783" value="83" name="data[Model][field][]">
<label for="FormData6783">Secondary</label>
</div>
it applies class to container div instead of input.. Is there any way to apply class to input ?
You will have to extend the FormHelper with your own helper and then overload the select method to change the code that generates the select. Check the BoostCake plugin to get an idea of one way o changing FormHelpers output.
You can then alias the helper to replace it app wide:
public $helpers = ['Form' => ['className' => 'MyForm']];
I'm trying to add button input to the form element. I'd like the rendered code to be <input type="button" ..."> I tried setting attribs field like so:
$this->addElement('submit', 'cancel', array(
'ignore' => true,
'label' => 'Anuluj',
'attribs'=>array('class' => 'class_name', 'type' => 'button') )
);
but i still got <input type="submit" ..."> instead <input type="button" ...">
Setting class attribute works, but setting the type doesn't. Any Idea to get type="button"?
Use button as the first parameter instead, which will give you a <button> HTML element instead (functionally the same as <input type="button" ..>).
Please use the below code for button
$this->addElement('button', 'submitted');
$submitElement = $this->getElement('submitted');
$submitElement->setAttrib('class',"btn-primary btn");
$submitElement->setAttrib('value', 'submitted');
$submitElement->setLabel('SUBMIT');
The Html code is,
<button name="submitted" id="submitted" type="button" class="btn-primary btn">SUBMIT</button>
my zend form generates following code:
<dt id="register_username-label">
<label for="register_username" class="required">Membername*</label>
</dt>
<dd id="register_username-element">
<input type="text" name="register_username" id="register_username" value="" />
</dd>
but in some cases (handled in a separete decorator) i need to add some more html next to the input field (also in the dd tag). i have a instance of Zend_Form_Element_Text witch i could add some more decorators, but i don't know how to get this done :(
solution should look like this:
<dt id="register_username-label">
<label for="register_username" class="required">Membername*</label>
</dt>
<dd id="register_username-element">
<input type="text" name="register_username" id="register_username" value="" />
<div class="validate"><div class="validate-check"></div></div>
</dd>
You can add decorators to your form element in form file just as below
$form->addElement(
'text',
'register_username',
array(
'required' => false,
'decorators' => array(
array(
'HtmlTag', array(
'tag' => 'div',
'class' => 'validate'
)
)
)
)
);
And more i would like to share with you one interesting Link to understand how zend form is basically works.
Please let me know if i can help you more.