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.')),
);
Related
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.
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
I can't disable escaping in a Zend_Form_Element_Submit, so when the label has special characters it won't display it's value..
This is my actual Zend Form piece of code:
$this->submit = new Zend_Form_Element_Submit('submit');
$this->submit->setLabel('Iniciar Sesión');
$this->submit->setIgnore(true);
$this->addElement($this->submit);
I've tried $this->submit->getDecorator('Label')->setOption('escape', false); but I obtain an "non-object" error (maybe submit isn't using the "Label" Decorator)..
I've also tried as suggested $this->submit->setAttrib('escape', false); but no text will be shown either.. Any idea? Thanks
Should be as simple as doing this:
$element->addDecorator('Label', аrray('escape'=>false));
Or see setEscape(). http://framework.zend.com/manual/1.12/en/zend.form.standardDecorators.html
Regarding failure to retrieve named decorator... Try getDecorators() Do you see 'label' in the results?
There is no Label decorator for submit form element by default (this is why you get the error).
The $this->submit->setLabel('Iniciar Sesión'); value goes to Zend_View_Helper_FormSubmit, which always does escaping and uses the label as a value.
The helper used by the Submit element escapes by default. Unlike with the label decorator, submit labels are included in a HTML attribute so they need to be escaped.
Your label - Iniciar Sesión - is a perfectly valid UTF-8 string, so the escaped version of it will be the same. If your label is not appearing then something else is going wrong. I'd guess that your page is being served using a charset that doesn't match what Zend View is using (UTF-8 by default).
View the page source to see what actually gets output - that might give you some more clues. Alternatively if the page this form is on is public, if you can provide a URL we might be able to spot the issue.
I ran into a similar issue. In my instance, I added both a label and a description to a text field element. This line of code allowed me to turn off the html escaping for the description attached to that field element:
$form->getElement('txtUPC')->getDecorator('description')->setOption('escape', false);
In my testing, the setEscape() was not recognized by the form elements or their decorators.
I am newer to wordpress.i have created a form using form builder.and included in a page.The form displays in the default template but not in the custom template.any idea??
// Formbuilder manual form display. Replace the # in the following line with the ID number of the form to be displayed.
if(function_exists('formbuilder_process_form')) echo formbuilder_process_form(#);
// End of FormBuilder manual form display.
I looked through the developer blogs and I can only find ways to create a custom global form button or to replace a field with custom code. I don't want to replace the field, I want to add a button beside a field.
Here's what I have in mind:
[Date Field][date_picker_button] [time field][time_is_now]
The button I want to add is the time_is_now, allowing the user to populate the time field with the current time.
I have tried updating custom/modules/Notes/metadata/quickcreatedefs.php with:
array (
'name' => 'billable_start_c',
'label' => 'LBL_BILLABLE_START',
'customCode' => '<button</button>',
)
But this replaces the input field with the custom code. I could just put in the stock code and then my custom code, but date fields use yui and a widget, so I'd prefer not to.
Is there anyway to do something like:
'customCode' => '{default} <button></button>',
so that the default code gets output and then the custom code?
You could create a new SugarField template, which will essentially allow you to create the markup for your field. If you named your SugarField TimeIsNow, you could create a field with that type (instead of text,int, date or whatever). You should take a look at some of the other SugarFields to see how they are formatted, but it's really just HTML. When the field is set to that type, it pulls in that HTML template. You can tie your JS to the onclick function. Sugar is very easy to customize, so I definitely wouldn't get in the habit of solving all your customization needs this way...It's another way to look at it though.
Don't use custom code if you can help it. Either copy over the tpl to custom/modules/[yourmodule]/tpls/[yourtemplate] and code the bitton in there or use an after_ui_frame hook and some js to insert you custom button into the DOM.