I have tried to limit number of rows in textarea to 4 but its giving error
Message: Array to string conversion
this is my code of textarea using helper class
$textarea_options = array('class' => 'form-control','rows' => 4, 'cols' => 40);
echo form_textarea('vc_desc', set_value('vc_desc'), $textarea_options);
setup a $data array instead with all the options
$data = array(
'name' => 'vc_desc',
'id' => 'vc_desc',
'value' => set_value('vc_desc'),
'rows' => '50',
'cols' => '10',
'style' => 'width:50%',
'class' => 'form-control'
);
echo form_textarea($data);
Use rows and cols to get change the height and length of text area in code ignitor.
$data = array('name' => 'SupAddress','value' =>set_value('SupAddress'), 'id'=>'SupAddress', 'class' => 'form-control' ,'readonly' => 'true' ,'rows' => '3', 'cols' => '40');
echo Form_textarea($data);
Related
I am trying to create a configurable product and its associated product using magento soap api.Product created successfully but configurable product linking with associated product is not working properly guys any idea? This is my code
<?php
$client = new SoapClient('https://sample.com/api/v2_soap?wsdl=1');
// If some stuff requires api authentification,
// then get a session token
$session = $client->login('username', 'Password');
// get attribute set
$attributeSets = $client->catalogProductAttributeSetList($session);
$attributeSet = current($attributeSets);
print_r($attributeSet);
$result = $client->catalogProductCreate($session, 'simple',72, 'product_sku0002', array(
'categories' => array(2),
'websites' => array(1),
'name' => 'Product name',
'description' => 'Product description',
'short_description' => 'Product short description',
'weight' => '10',
'status' => '1',
'url_key' => 'product-url-key',
'url_path' => 'product-url-path',
'visibility' => '4',
'price' => '100',
'tax_class_id' => 1,
'meta_title' => 'Product meta title',
'meta_keyword' => 'Product meta keyword',
'meta_description' => 'Product meta description',
'additional_attributes' => array(
'single_data' => array(
array(
'key' => 'color',
'value' => 'Red', // Id or label of color, attribute that will be used to configure product
)
),
),
));
var_dump ($result);
$result = $client->catalogProductCreate($session, 'configurable',72, 'Configurable_product_sku0001', array(
'categories' => array(2),
'websites' => array(1),
'name' => 'Confihurable Product name',
'description' => 'Product description',
'short_description' => 'Product short description',
'weight' => '10',
'status' => '1',
'url_key' => 'product-url-key',
'url_path' => 'product-url-path',
'visibility' => '4',
'price' => '100',
'tax_class_id' => 1,
'meta_title' => 'Product meta title',
'meta_keyword' => 'Product meta keyword',
'meta_description' => 'Product meta description',
'associated_skus' => array('product_sku0002'),
'price_changes' => array(
array(
'color' => array(
'Red' => '0'
)
),
),
));
var_dump ($result);
?>
Its working fine using this method follow the link
http://www.bubblecode.net/en/2012/04/20/magento-api-associate-simple-products-to-configurable-or-grouped-product/
I wanted to fetch the selected value from the database and display it in codeigniter form_dropdown() function but it displays wrong.
Controller:
$type = array(
'options' => array(
'section' => 'Section',
'transaction' => 'Transaction',
'document' => 'Document'
),
'attributes' => array(
'class' => 'form-control'
)
);
View:
<?php echo form_dropdown('type', $type['options'],'', $type['attributes']) ?>
The Screenshot
Try the below code:
Controller:
$this->data['type'] = array(
'name' => 'type_value',
'attributes' => 'class="form-control"',
'value' => (isset($database_type_value) && trim($database_type_value)) ? $database_type_value: $this->input->post('type_value',TRUE), //$database_type_value - value from database
'options_list' => array(
'section' => 'Section',
'transaction' => 'Transaction',
'document' => 'Document'
),
);
View:
<?php echo form_dropdown($type['name'],$type['options_list'],$type['value'],$type['attributes']);?>
i use the following fieldset for grouping information:
<input type='text' name='personal[firstname]'>
<input type='text' name='personal[lastname]'>
Now i want to use an InputFilter to validate the form, but nothing happens:
class CustomerFilter extends InputFilter
/**
* Build filter
*/
public function init()
{
$this->add(array(
'name' => 'personal[firstname]',
'required' => true,
'filters' => array(
array('name' => 'StringTrim'),
array('name' => 'StripTags'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'min' => 3,
'max' => 15,
'message' => 'Minimum: 3, Maximum 15 Chars allowed'
),
),
),
));
}
What do i have to change?
EDIT:
Finally, i managed it with help of this link:
http://framework.zend.com/manual/2.2/en/modules/zend.form.collections.html
No need of array dude,
Remove array[] in zend validation
<input type='text' name='personal[firstname]'>
<input type='text' name='personal[lastname]'>
class CustomerFilter extends InputFilter
/**
* Build filter
**/
public function init()
{
$this->add(array(
'name' => 'personal',
'required' => true,
'filters' => array(
array('name' => 'StringTrim'),
array('name' => 'StripTags'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'min' => 3,
'max' => 15,
'message' => 'Minimum: 3, Maximum 15 Chars allowed'
),
),
),
));
}
I created custom module and now from admin side on edit form i added extra field select type.
I want to change comments with onchange function for this specific field.See below my code.
$eventElem = $fieldset->addField('banner_type', 'select', array(
'label' => Mage::helper('multibanners')->__('Banner Style'),
'required' => false,
'onchange' => 'checkSelectedItem(this.value)',
'name' => 'banner_type',
'values' => array(
array(
'value' => 'Banner 1',
'label' => 'AnySlider',
),
array(
'value' => 'Banner 2',
'label' => 'Content Slider',
),
));
$eventElem->setAfterElementHtml("<script type=\"text/javascript\">function checkSelectedItem(selectElement){}</script>");
This is my code i alert the value and i got my value but it cannot show it in comments area .Did someone one know how to fix it ?
Thanks
This will update the comment (onchange) with the current selected option
$fieldset->addField('banner_type', 'select', array(
'label' => Mage::helper('multibanners')->__('Banner Style'),
'required' => false,
'onchange' => 'checkSelectedItem(this.value)',
'name' => 'banner_type',
'values' => array(
array(
'value' => 'Banner 1',
'label' => 'AnySlider',
),
array(
'value' => 'Banner 2',
'label' => 'Content Slider',
),
)
))->setAfterElementHtml("<small id='banner_type_comment'>Comments</small>
<script type=\"text/javascript\">
function checkSelectedItem(selectElement){
$('banner_type_comment').update($('banner_type')[$('banner_type').selectedIndex].text);
}
</script>");
I have a custom module where I create a form.
One field is a dropdown with values from a flat file.
$fields = array(
'type_of_service' => array('display' => 'Tip serviciu',
'required' => true,
'type' => 'select',
'options' => $serviceTypeOptions,
How can I set one value to be selected ?
EDIT:
if I use something like this in _prepareForm()
$fieldset->addField('select', 'select', array(
'label' => Mage::helper('tracking')->__('Select'),
'class' => 'required-entry',
'required' => true,
'name' => 'title',
'value' => '3',
'values' => array('-1'=>'Please Select..','1' => 'Option1','2' => 'Option2', '3' => 'Option3'),
)),
preselected will be 3.
But I generate my fields previously, and assign those to form with
$formFields = $this->getFormFields();
The problem is that I can't use the addField method, I need to have them created within my function.
Thanks.
try this,
'required' => true,
'value' => '2',
'values' => array(
array('1' => 'Option 1','2' => 'Option 2'),
...
which will select Option 2.
Try this
'required' => true,
'value' => 2,
'values' => array(
array('label' => 'Option 2', value => 2),
array('label' => 'Option 1', value => 1)
)
A full example can be like below
$fieldset->addField(
'target_type',
'select',
array(
'label' => $this->__("Target Type"),
'class' => 'required-entry',
'required' => 'true',
'name' => 'target_type',
'note' => $this->__("Target Type"),
'value' => 2,
'values' => array(
array(
'value' => 2,
'label' => 'Option 2'
)
)
)
);
NOTE : If you want to know about any of the Varien_Data_Form_Elements, you can directly do an inspection of Varien library /lib/Varien/Data/Form/Element/Select.php in your case.