BoonEx Dolphin: Alter the Add a New Group form - php

When adding a new group in BoonEx Dolphin, there is an HTML form that contains several input fields. Among the fields, there are Country, City, Zip/Postal Code - how can I remove those from the form?

Group/Add Group/ Group'sInfo
Here is the answer for your question. Refer this link.
edit the file "modules/boonex/events/classes/BxEventsFormAdd.php"
here you see this for country:
'Country' => array(
'type' => 'select',
'name' => 'Country',
'caption' => _t('_bx_events_caption_country'),
'values' => $aCountries,
'required' => true,
'checker' => array (
'func' => 'preg',
'params' => array('/^[a-zA-Z]{2}$/'),
'error' => _t ('_bx_events_err_country'),
),
'db' => array (
'pass' => 'Preg',
'params' => array('/([a-zA-Z]{2})/'),
),
),
delete the line:
'required' => true,
same for city and place, or you could try to delete the whole code from above
for groups the same on the file:
modules/boonex/groups/classes/BxGroupsFormAdd.php
Here is the link for more details:
http://www.boonex.com/forums/topic/Remove-Country-from-mandatory-field-in-Groups-and-Events.htm

Related

Adding a dropdown menu in Prestashop 1.7 module

I'm so beginner in Prestashop 1.7, I wanted to add a dropdown select section in my banner module to select the way to open the banner link.
but the selected value is never passed to the HTML, the code below IS passed but the one under isn't, can you please assist me?
[enter image description here][1]
array(
'type' => 'text',
'lang' => true,
'label' => $this->trans('Banner description', array(), 'Modules.Banner.Admin'),
'name' => 'BANNER_DESC',
'desc' => $this->trans('Please enter a short but meaningful description for the banner.', array(), 'Modules.Banner.Admin')
)
array(
'type' => 'select', //select
'lang' => true,
'label' => $this->trans('Banner tab', array(), 'Modules.Banner.Admin'),
'name' => 'BANNER_TAB',
'required'=>'true',
'options' => array(
'query' => array(
array('key' => '_blank', 'name' => 'New tab'),
array('key' => '_self', 'name' => 'Same tab'),
),
'id' => 'key',
'name' => 'name'
),
'desc' => $this->trans('Please select the way to open the link.', array(), 'Modules.Banner.Admin')
)
This is how it looks in the Backoffice:
Here
You not only need to add a new field to your form but also handle saving the data from it.
Take a look at a few examples:
https://github.com/PrestaShop/ps_featuredproducts/blob/dev/ps_featuredproducts.php#L122
Notice how the module author managed to save each configuration field from the form. This is what you need to do.
If you want to have access to data in your view, you have to pass it:
https://github.com/PrestaShop/ps_featuredproducts/blob/dev/ps_featuredproducts.php#L244
Maybe after you added a new field, you forgot to handle the saving + passing to the view?

How to validate multiply select using Zend Framework 2

I am trying to validate a multiply select using input filter, but every time I see a error. The error is "notInArray":"The input was not found in the haystack".(I use ajax but it doesn`t metter).
I will show part of my code to be more clear.
in Controller:
if ($request->isPost()) {
$post = $request->getPost();
$form = new \Settings\Form\AddUserForm($roles);//
$form->get('positions')
->setOptions(
array('value_options'=> $post['positions']));
//.... more code...
When I put print_r($post['positions']); I see:
array(0 => 118, 1 => 119)
in ..../form/UserForm.php I create the multiply element
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'attributes' => array(
'multiple' => 'multiple',
'id' => 'choosed_positions',
),
'required' => false,
'name' => 'positions',
));
and in the validation file the code is:
$inputFilter->add($factory->createInput(array(
'name' => 'positions',
'required' => false,
'validators' => array(
array(
'name' => 'InArray',
'options' => array(
'haystack' => array(118,119),
'messages' => array(
'notInArray' => 'Please select your position !'
),
),
),
),
What can be the reason every time to see this error, and how I can fix it?
By default selects have attached InArray validator in Zend Framework 2.
If you are adding new one - you will have two.
You should disable default one as follow:
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'options' => array(
'disable_inarray_validator' => true, // <-- disable
),
'attributes' => array(
'multiple' => 'multiple',
'id' => 'choosed_positions',
),
'required' => false,
'name' => 'positions',
));
And you should get rid of the additional error message.
Please let us know if that would helped you.

Defining multiple streams and adding fields to each of them in PyroCMS

I am new to PyroCMS and am willing to build a Job Site wherein there'll be 2 main users namely, Employers and Job Seekers. In order to allow them to register on the site, I'm using the Streams API from PyroCMS to build the forms. These users will be part of 2 different modules namely the Employer module and the Job Seeker module.
In the details.php file, under the install() function, I want to create multiple streams(database tables). The following code helps us to add a stream:
$this->streams->streams->add_stream();
The following code then helps us to define the fields to be added to the stream:
$this->streams->fields->add_fields($fields);
My concern is how do I add multiple streams like the above ones and add fields to each of them? In other words, how would the syntax
$this->streams->fields->add_fields($fields);
know which stream to add the fields to?
Have a look at the Fields Driver documentation for the Streams API. Fields and streams are separate entities, with no required association between the two. When adding a field you can assign it to a stream like this:
$field = array(
'name' => 'Question',
'slug' => 'question',
'namespace' => 'streams_sample',
'type' => 'text',
'extra' => array('max_length' => 200),
'assign' => 'STREAM_SLUG_GOES_HERE',
'title_column' => true,
'required' => true,
'unique' => true
);
$this->streams->fields->add_field($field);
Or you can create the streams and fields separately, and then assign each field to a stream like this:
$this->streams->fields->assign_field('streams_sample', 'STREAM_SLUG_GOES_HERE', 'question', array('required' => true));
All this talk of fields and streams makes me want to go outside...
You can add multiple streams like this example.
// Add banners streams
if ( ! $this->streams->streams->add_stream(lang('banner:banners'), 'banners', 'banner', 'banner_', null)) return false;
// Add groups streams
if ( ! $this->streams->streams->add_stream(lang('banner:groups'), 'groups', 'banner', 'banner_', null)) return false;
// Add some fields
$fields = array(
// BANNERS
array(
'name' => 'Banner Title',
'slug' => 'banner_title',
'namespace' => 'banner',
'assign' => 'banners',
'type' => 'text',
'extra' => array('max_length' => 200),
'title_column' => true,
'required' => true,
'unique' => true
),
// GROUPS
array(
'name' => 'Group Title',
'slug' => 'group_title',
'namespace' => 'banner',
'assign' => 'groups',
'type' => 'text',
'extra' => array('max_length' => 200),
'title_column' => true,
'required' => true,
'unique' => true
)
);
$this->streams->fields->add_fields($fields);

Magento adminhtml form fields not adding to POST

I have the following fields in a magento adminhtml form.
On submit im expecting to grab the post, and simply dump its contents, which im doing in my saveAction.
public function saveAction()
{
if ($this->getRequest()->getPost())
{
try{
$postData = $this->getRequest()->getPost();
echo '<pre>';
print_r($postData);
exit;
the output looks as follows.
Array
(
[form_key] => I6jK6swe1EMl0wER
[carrier_code] => test
[postcode] => tescode
[sku] => 123445
)
Seeing my form is defined as:
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('instance_form', array('legend'=>Mage::helper('instance')->__('Instance Filters')));
$fieldset->addField('carrier_code', 'text', array(
'label' => Mage::helper('instance')->__('Carrier service'),
'name' => 'carrier_code',
'after_element_html' => '<small>Leave blank for all Carriers.</small>',
));
$fieldset->addField('postcode', 'text', array(
'label' => Mage::helper('instance')->__('Postcode'),
'name' => 'postcode',
'after_element_html' => '<small>Leave blank for all Postcodes.</small>',
));
$fieldset->addField('sku', 'text', array(
'label' => Mage::helper('instance')->__('Sku'),
'name' => 'sku',
'after_element_html' => '<small>Leave blank for all Skus.</small>',
));
$fieldset->addField('start_date', 'date', array(
'label' => Mage::helper('instance')->__('Start Date'),
'after_element_html' => '<small>Comments</small>',
'tabindex' => 1,
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
));
$fieldset->addField('aura', 'file', array(
'label' => Mage::helper('instance')->__('Upload'),
'value' => 'Uplaod',
'disabled' => false,
'readonly' => true,
'after_element_html' => '<small>Comments</small>',
'tabindex' => 1
));
I was expecting to see output like this instead :
Array
(
[form_key] => I6jK6swe1EMl0wER
[carrier_code] => test
[postcode] => tescode
[sku] => 123445
[start_date] => someValue
[aura] => anotherValue
)
am i missing something? why would say the date field, not be added to the post, like all the other text input fields?
Cheers
You're missing the name key in your addField('start_date', ..) call.
Each field of a Varien_Data_Form you want to be submittable needs a name key/value pair.
The value you assign to your field's name key is used as value for the name attribute of the corresponding <input> element when rendering the <form>.

How to add new fields to user profile in Drupal 7 programmatically

I want to develop a module that add fields to user profile in drupal 7, like phone number and CV ...
and I don't know how to do that (using Database or using fields API)
pls help me.
Any clear tutorials will be appreciated.
Try to follow the following code
$myField_name = "NEW_FIELD_NAME";
if(!field_info_field($myField_name)) // check if the field already exists.
{
$field = array(
'field_name' => $myField_name,
'type' => 'text',
);
field_create_field($field);
$field_instance = array(
'field_name' => $myField_name,
'entity_type' => 'user', // change this to 'node' to add attach the field to a node
'bundle' => 'user', // if chosen 'node', type here the machine name of the content type. e.g. 'page'
'label' => t('Field Label'),
'description' => t(''),
'widget' => array(
'type' => 'text_textfield',
'weight' => 10,
),
'formatter' => array(
'label' => t('field formatter label'),
'format' => 'text_default'
),
'settings' => array(
)
);
field_create_instance($field_instance);
Hope this works... Muhammad.

Categories