Is there a way that I can put a green tick or a red cross, and a process bar"Circular" besides a label in my forms? Basically I need to show if user has inputted text or not and if he/she is still inputting text, should I use ajax with zend? if so please give tips I am using Zend. Something like this image at the end of the link
How to put green tick or red cross in winforms?
Thanks.
Zend is handling your server side logic and performs all the HTML generation, filtration, validation, etc. If you want Zend to generate additional code for your elements you will have to create a new form element decorator or layout your form manually using template (display each element separately instead of just <?= $form ?>. You can also look into ZendX project.
I suggest you take a little different route and add client layer for presentation.
For example, when you define the element add certain classes to it...
$elem = new Zend_Form_Element_Text('my_element', array(
'class' => 'required validate-phone ui-icon-phone'
));
On client side add some CSS
input[type=text].ui-icon-phone {
background: url(...);
}
On client side add JS to bind to the classes of elements to do validation. I'd suggest to use jquery validation plugin... you can overload the way messages are displayed and user red X on invalid inputs. Also, look into Masked Input Plugin (see demo).
With such approach your service side code is independent of the client side code.
Related
I'd like to have a custom select field with 3 options: dog, cat, other - and when the other is selected I'd like the blank text input to appear below to allow user to write his favourite animal in it.
Is there a way to conditionally render field based on option selected?
<%=
select f, :animal, [
{"Dog", :dog},
{"Cat", :cat},
{"Other", :other}
]
text_input f, :animal
%>
You can't achieve it without the help of JavaScript.
HTML tags are rendered on the server side and the choice of option takes place on the browser.
If you don't want to write JavaScript code, try Phoenix LiveView, which allows you to change the DOM tree dynamically on the server side.
A JavaScript library works behind the Phoenix LiveView, but you will hardly notice it.
I am building a multi-step application form with React. Having first built it with pure internal state I am now in the process of refactoring to Redux using redux-form.
Having used the example here as a basis: http://redux-form.com/5.2.5/#/examples/wizard?_k=oftw7a we have come a good way.
However the problem appears when i have two forms which are supposed to have the same value. During one of the pages i have a name field, that is supposed to be duplicated on the name field of the next page. The opposite should happen if you go back from the last page. Any tips to how this could be achieved?
Using the wizard, you are basically working with the exact same form that's split into multiple pieces. Ultimately it's the same form, because redux-form tracks them by name. It is how the library identifies the pieces of the same form - using the name.
form: 'wizard',
Here you can see that the exact same instance of the form will be shared throughout the pieces. fields work in a similar manner. Each field is defined as part of a form.
As long as you use the same field constants inside the fields object that you pass into the reduxForm function and as long as the value for form is the same, so that they use the same underlying form object, it should work for you just fine.
On one page you should pass in
export default reduxForm({
form: 'wizard',
fields : {
'fieldIWantOnBothPartsOfTheForm',
'someOtherFieldThatShouldOnlyBeHere',
},
...
And then on the other page:
export default reduxForm({
form: 'wizard',
fields : {
'fieldIWantOnBothPartsOfTheForm',
'thirdFieldHere',
},
...
Also, make sure you keep destroyOnUnmount equal to false if you want to navigate back-and-forth.
Hope that helps.
How can I change the positions of checkbox and label and how to implement a link into the label?
$acceptGTC = new Element\Checkbox('AGBs');
$acceptGTC->setLabel('I Accept the GTC (show it).');
$this->add($acceptGTC);
regards
n00n
meanwhile:
I tried to overwrite the view helper for checkboxes.
copied
*/vendor/zendframework/zend-form/src/View/Helper/FormCheckbox.php
to
*/module/Application/src/Application/View/Helper/FormCheckbox.php
added to module.config.php
'viewhelpers' => array('checkbox'=>'Application\View\Helper'),
But it still uses the original one...
Do I have to tell zend to use my FormCheckbox?
I don't exactly know the way you are rendering your Zend_Form_Element, but in order to enhance the rendering as you want you should build a custom decorator, and add it to this element.
You should read the Zend documentation on Zend_Form_Decorators, everything is quite well explained and should lead you to a fancy solution.
I am using Plesk Sample 1.5-1 as a base, but stuck on how to process POST w/parameters.
My form is a 'text' element and 'ok' submit button and below that is a list that will change based on the value of the 'text' element (external XML call).
Inside IndexController, in the ->getRequest->isPost() area, I have a redirect line:
$this->_helper->json(array('redirect' => pm_Context::getBaseUrl()));
Do I have to manually pass the parameters on this line? Or does the controller know because I created a pm_Form_Simple() and added elements? Right now if I am outside the ->isPost block, the parameters are null, so that is why I am thinking I have to manually pass them along.
Do I need something like this?
$this->_redirector->gotoSimple('my-action',
'my-controller',
null,
array('exampleText' => $form->getValue('exampleText'));
I guess am just not understanding how the POST works.
I have looked at the Zend Guestbook example, but it is different enough from Plesk that I can't mentally translate it...and it doesn't redirect to the same page, it redirects some where else.
Ultimately, I want to set the 'exampleText' parameter with a "start date" and after the POST call, make an external XML call and fill out the list... I can make the XML call, but can't get the workflow around empty form -> fill out form and press "ok" -> post processing
thx!
Turns out that the pm_Form_Simple needs JSON I didn't notice that my orig code had JSON but didn't encode the new code...
I'm trying to add a plain text node in a custom drupal form. The purpose is to only dispay some static text.
The problem is - im not aware of any such way to do it.
I have used 'description' but that HAS to be attached to a form element.
Is there any way to simply display some text as part of a form?
Eg:
The following will test your ability on so and so. . . .
etc...
Any thoughts?
You should be able to add text using the markup form element.
Description: Generate generic markup for display inside forms.
Example from the documentation:
$form['contact_information'] = array(
'#markup' => variable_get('contact_form_information',
t('You can leave us a message using the contact form
below.')),
);