How to make three dropdown in same line,Using zend form - zend-framework

I have a page , where i need to show 3 drop down in same line.
Iam generating these drop downs using zend form.
Now the drop down is coming one line after one line.
How can we make it in same line

Zend form comes with decorators. If decorators are set (which is used for template theming purpose) with '' or any other Html tag then there is a possibility that the element will be displayed in new line. Try with removing decorators.
Or you can generate select element dyanamicly on .phtml (view file) by using code
$this->formSelect("ID", "default value", array('style' => 'width:60px', 'class' => 'progDiv'), $options);
Where $options is an array of select box options like `$options = array(''=>'', 1=>'option1', 2=>'option2');`
If this does not solve your query please try to post your code
Thanks

Related

Zend tick and cross next to input box

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.

How to add plain text node to drupal form?

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.')),
);

How do i preserve form input - after submiting form with dynamic menu list ?? Zend framework

Im trying to preserve the user inputs from dynamic menu dropdown lists - I have an number of drowpdowns and a user input text field , when the user submits the form after selecting the options from the dropdowns.
I would like to be able to preserve the last choices made so the user does not have to reselect the options again when re posting the form with another value in the text field, i would also like this to work on errors as well ?
Im using ZF to validate the form.
i have tried the follwing code in the value attr of the option:
<option value="<?php if ($_POST && errors) {
echo htmlentities($_POST['CategoryID'], ENT_COMPAT, 'UTF-8');
}?>">Main Category</option>
But does not seem to work ?
I have a static options "Main Category" ect. which is what the form defaults to after submiting
can anyone help me on this one ??
Thanks in advance
I would highly recommend using Zend_Form. If that is not possible, I would next use Zend_View Helpers to build your HTML manually. Then you can use the formSelect in your view like this:
echo $this->formSelect('CategoryId', $selected, $attribs, array(
'main' => 'Main Category'
// ... other options
));
Where $selected variable equals to one of the following: posted value(s), default value(s), or is null and $attribs variable is simply attributes for the select element.

How do I get a regular Checkbox in a Zend Form?

I have a form in Zend_Form that needs some checkboxes and I'd like them to be regular old checkboxes. You know, you give em a name and a value. If they are checked your post data contains name=>value.
Zend_Form is generating two inputs fields. One, the checkbox with a value=1 and the second a hidden input with a value=2. Both have the same name. I understand in theory how Zend expects the checkbox to work, but that's not how I expect it to work and it's not how I want it to work. How do I get my old fashion HTML checkbox back?
I have tried using $this->createElement, $this->addElement and creating a Zend_Form_Element_Checkbox manually. None allow me to set the checkbox's value and all generate the hidden input.
The final and REALLY correct answer is to add an option to the element :
$this->addElement('checkbox', 'my_element', array(
'label' => 'My Element Label',
'name' => 'my_element_name',
'disableHidden' => true
));
Zend_Form_Element_MultiCheckbox is what you're looking for.
The standard Checkbox element is meant to represent "yes/no" scenarios.
You could extend Zend library and add your own custom form element to render it just like you expect it. I did it for having a date field and it worked just fine.
I wonder why that does not work for you. You can set the values to anything you want (setCheckedValue() and setUncheckedValue()). So the only difference to normal checkbox is
if (null == $this->_getParam('checkbox', null)) {
//vs.
if ($unchecked == $this->_getParam('checkbox')) {
What exactly are you trying to do?

Drupal 6 - How to customise form layout using theme

I have create a new content type and added new form items using CCK. I need to customise the layout of the form which I've partially managed using css and moving items around and adding custom markup in the form_alter hook. However, this still isn't enough as the weightings don't appear to be doing exactly what I want them to do.
Is there a way I can do this using a theme.tpl.php file?
Thanks
Steve
once in a time I was in the same situation and found a quite easy solution.
I needed a highly customized registration form and form_alter was a mess. So I used a template for the form and printed each field into the html output.
First register a new template for the form in template.php of you theme.
<?php
function your-theme-name_theme() {
return array(
'user_register' => array(
'arguments' => array('form' => NULL),
'template' => 'user-register',
),
);
}
?>
Now add a new template to your theme. In my case "user_register.tpl.php". Add the following lines to it, so that the form still works.
<?php
print drupal_render($form['form_build_id']);
print drupal_render($form['form_id']);
print drupal_render($form['form_token']);
?>
From there on you can add as much html as you want and put the form fields where ever you need them. Here are examples for the gender and birthday field. As you can see you have to use the internal CCK names.
<?php print drupal_render($form['field_profile_gender']); ?>
<?php print drupal_render($form['field_profile_birthday']); ?>
I have not tested this for any other form than user_register, but I guess it should work as long as the template name equals the name of the form.
I hope this will help you.
Regards
Mike