Pass different class name - symfony1

I do have the following form:
'region' => new sfWidgetFormChoice(array('expanded' => true,'choices' => $region))
I get the folloing html.
<ul class="radio_list">
<li> first...
<li> second....
I want to change the name of class in the table. It shouldn't be radio_list. I want to name it by my own?
How can I do it in 'region'?
Following is not working and changes the classes of <li>:
'region' => new sfWidgetFormChoice(array('expanded' => true,'choices' => $region), array('class' => 'your_class'))
Thanks!
Gunnar
This is my complete Widget:
$this->setWidgets(array(
'recipename' => new sfWidgetFormInputText(array(), array('size' => '40', 'maxlength' => '150')),
'description' => new sfWidgetFormInputText(array(), array('size' => '40', 'maxlength' => '100')),
'ingredients' => new sfWidgetFormTextarea(array(), array('rows' => '10', 'cols' => '35')),
'preparation' => new sfWidgetFormTextarea(array(), array('rows' => '10', 'cols' => '35')),
'kis' => new sfWidgetFormChoice(array('expanded' => true, 'choices' => $kis)),
'category' => new sfWidgetFormChoice(array('expanded' => true, 'choices' => $category)),
'region' => new sfWidgetFormChoice(array('expanded' => true, 'choices' => $region)),
));

You need to use renderer_options for that, since sfWidgetFormSelectRadio overrides passed attribute with it's own option.
new sfWidgetFormChoice(array(
'expanded' => true,
'choices' => $region,
'renderer_options' => array(
'class' => 'your_class'
)
);

Related

Drupal 8 CiviCRM Create user invalid session key

I have a custom module where i create custom registration forms for drupal users with different roles. It was working good till i installed CiviCRM
When a form is submitted, it says:
Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
We can't load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site administrator for assistance.Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.Error type: Could not find a valid session key.
My code:
public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
$account = entity_create('user');
$account->setUsername($form_state->getValue('uname'))->setEmail($form_state->getValue('email'));
$account->addRole('private');
$account->activate();
$account->save();
}
Checked for my Resource urls for Civi but they are correct.
Drupal: 8.4.0
CiviCRM: 4.7.28
Found it!
If you build a custom form, Civi need some fields for when a new Drupal user is created.
1: Go to Civi profiles (/civicrm/admin/uf/group?reset=1) and select the desired profile you want to include in the form. I selected "Your registration form".
Go to settings of the profile and select "used for => Drupal User Registration"
In Advanced Settings check Account creation required
2: In your custom form, implement the function: 'civicrm_form_user_register_form_alter'.
public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
$validators = array(
'file_validate_extensions' => array('jpg jpeg png'),
);
$form['uname'] = array(
'#type' => 'textfield',
'#placeholder' => t('Username*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['organisation'] = array(
'#type' => 'textfield',
'#placeholder' => t('Organisation name*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['password'] = array(
'#type' => 'password_confirm',
'#placeholder' => t('Password*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['name'] = array(
'#type' => 'textfield',
'#placeholder' => t('Full Name*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['email'] = array(
'#type' => 'email',
'#placeholder' => t('Email Address*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['street'] = array(
'#type' => 'textfield',
'#placeholder' => t('Street*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['nr'] = array(
'#type' => 'textfield',
'#placeholder' => t('Nr*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['zipcode'] = array(
'#type' => 'textfield',
'#placeholder' => t('Zipcode*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
$form['city'] = array(
'#type' => 'textfield',
'#placeholder' => t('City*'),
'#required' => TRUE,
'#attributes' => array('class' => array('form-control')),
);
//This did the trick!
if( function_exists('civicrm_form_user_register_form_alter') ) {
civicrm_form_user_register_form_alter($form,$form_state,'customRegistration');
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Create'),
'#attributes' => array('class' => array('btn', 'btn-cs', 'btn-outline')),
);
$form['#validate'][] = array($this, 'regValidate');
return $form;
}
2: In your template, add the fields with the field name from the Civi function:
{{custom_registration_form.civicrm_profile_register}}
You find the name in /modules/civicrm-drupal/civicrm.module
$form['civicrm_profile_register'] = array(
'#markup' => \Drupal\Core\Render\Markup::create($html),
'#cache' => [
'max-age' => 0,
],
);
The fields from the profile will be included in your custom form and no problems with sessions key anymore.

Typo3 FAL Extension Backend Upload

I have an Extension which holds a list of PDF-Docs.
In my TCA I defined the uploadfolder, but after uploading a file, it goes to "fileadmin/user_upload". Not to my defined folder "fileadmin/user_upload/my_folder"
My TCA
'pdfs' => array(
'exclude' => 0,
'label' => 'LLL:EXT:xxx/Resources/Private/Language/locallang_db.xlf:xxx_domain_model_pdflist.pdfs',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( 'pdfs',
array(
'maxitems' => 200,
'max_size' => 5000,
'uploadfolder' => 'fileadmin/user_upload/bffpdf',
'show_thumbs' => 1,
'size' => 20,
'minitems' => 0,
),
'pdf'
),
),
The Folder exists and is shown up in the Fileadmin.
I do not want to override the userdefault uploadfolder.
Greetz
Thomas
Am not familiar with typo3, but my following code works perfect for me, I think this may help you.
My TCA
'image' => array(
'exclude' => 0,
'label' => 'LLL:EXT:titech_catalog/locallang_db.xml:tx_titechcatalog_category.image',
'config' => array(
'type' => 'group',
'internal_type' => 'file',
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_titechcareers',
'show_thumbs' => 1,
'size' => 1,
'minitems' => 0,
'maxitems' => 10,
)
)
Code to create this path is in 'ext_emconf.php' file,
'createDirs' => 'uploads/tx_titechcareers/rte/',

select a SF2 choice option

My code for my form ( i am using Silex):
$test = array(
'Swedish Cars' => array(
'volvo' => 'Volvo',
'saab' => 'Saab',
),
'German Cars' => array(
'mercedes' => 'Mercedes',
'audi' => 'Audi'
)
);
$form = $app['form.factory']->createBuilder('form')
->add('title','text',array(
'attr' => array(
'placeholder' => 'Title of your Album'
)))
->add('description','textarea',array(
'attr' => array(
'placeholder' => 'Describe your Album'
)))
->add('groups', 'choice', array(
'choices' => $test,
'multiple' => true,
'attr' => array(
'data-placeholder' => 'Add your Groups ...'
),
))
The choices are defined as an multi-array, so I get <option> with <optgropup>. How can I enable in SF2, that some options are selected?
Use the data option:
->add('groups', 'choice', array(
'choices' => $test,
'multiple' => true,
'attr' => array(
'data-placeholder' => 'Add your Groups ...',
'data' => $selected_value
),
where $selected_value can be a single value like 'value_1' or an simple array with multiple values array('value_1', 'value_2') to select.

How to put default value in CJuidatepicker in Yii?

I have the code below to display a calendar input in Yii form.
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'publish_date',
'attribute' => 'publish_date',
'model'=>$model,
'options'=> array(
'dateFormat' =>'yy-mm-dd',
'defaultDate' => '2014-3-4',
'altFormat' =>'yy-mm-dd',
'changeMonth' => true,
'changeYear' => true,
'appendText' => 'yyyy-mm-dd',
),
));
?>
The default value work on the calendar but I want to show it by default in the calendar input too when the form is rendering.
How can I do it?
You can use Html value attribute for this
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'publish_date',
'attribute' => 'publish_date',
'model'=>$model,
'options'=> array(
'dateFormat' =>'yy-mm-dd',
'defaultDate' => '2014-3-4',
'altFormat' =>'yy-mm-dd',
'changeMonth' => true,
'changeYear' => true,
'appendText' => 'yyyy-mm-dd',
),
'htmlOptions'=>array('value'=>'2013-4-4')
));
Manquer's solution didn't work (in version 1.1.17), CJuiDatePicker extends from CJuiInputWidget and it has a value property which is used by CHtml::inputField() when rendering the element, overwriting the value field of htmlOptions property.
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'publish_date',
'attribute' => 'publish_date',
'model'=>$model,
'options'=> array(
'dateFormat' =>'yy-mm-dd',
'defaultDate' => '2014-3-4',
'altFormat' =>'yy-mm-dd',
'changeMonth' => true,
'changeYear' => true,
'appendText' => 'yyyy-mm-dd',
),
'value' => '2013-3-4',
));

Rails 3.1 - Split Column on Data import?

I'm importing sales data from iTunes successfully using:
FasterCSV.parse(uploaded_io, {:headers => true, :col_sep =>"\t"}).each do |row_data|
new_record = AppleSale.new(
'provider' => row_data[0],
'provider_country' => row_data[1],
'vendor_identifier' => row_data[2],
'upc' => row_data[3],
'isrc' => row_data[4],
'artist_show' => row_data[5],
'title' => row_data[6],
'label_studio_network' => row_data[7],
'product_type_identifier' => row_data[8],
'units' => row_data[9],
'royalty_price' => row_data[10],
'download_date' => row_data[11],
'order_id' => row_data[12],
'postal_code' => row_data[13],
'customer_identifier' => row_data[14],
'report_date' => row_data[15],
'sale_return' => row_data[16],
'customer_currency' => row_data[17],
'country_code' => row_data[18],
'royalty_currency' => row_data[19],
'preorder' => row_data[20],
'isan' => row_data[21],
'customer_price' => row_data[22],
'apple_identifier' => row_data[23],
'cma' => row_data[24],
'asset_content_flavor' => row_data[25],
'vendor_order_code' => row_data[26],
'grid' => row_data[27],
'promo_code' => row_data[28],
'parent_identifier' => row_data[29]
)
new_record.save
end
'vendor_order_code' however contains values like '0711297494143_CADE70900648' that i'd like to split on the underscore and store in two separate (new) columns. Not all entries have a value like this, some just contain the first part (a UPC). I realise there are already UPC and ISRC columns provided but these aren't populated in a way that's useful to me, splitting the vendor_order_code is the only way I can do what I need to do.
Can anyone suggest the correct way of doing this? I know the below is complete nonsense, but i'm thinking something along the lines of:
'vendor_order_code' => row_data[26],
'vendor_order_code_UPC' => row_data[26].split("_")...and save just the first half regardless of whether split occurred.
'vendor_order_code_ISRC' => row_data[26].split("_")..and save just the second half if it exists
No need for multiple splits and/or conditionals; just match once per row.
FasterCSV.parse(uploaded_io, {:headers => true, :col_sep =>"\t"}).each do |row_data|
full, upc, _discard, isrc = row_data[26].match(/^([^_]+)(_(.+))?/).to_a
new_record = AppleSale.new(
'provider' => row_data[0],
'provider_country' => row_data[1],
'vendor_identifier' => row_data[2],
'upc' => row_data[3],
'isrc' => row_data[4],
'artist_show' => row_data[5],
'title' => row_data[6],
'label_studio_network' => row_data[7],
'product_type_identifier' => row_data[8],
'units' => row_data[9],
'royalty_price' => row_data[10],
'download_date' => row_data[11],
'order_id' => row_data[12],
'postal_code' => row_data[13],
'customer_identifier' => row_data[14],
'report_date' => row_data[15],
'sale_return' => row_data[16],
'customer_currency' => row_data[17],
'country_code' => row_data[18],
'royalty_currency' => row_data[19],
'preorder' => row_data[20],
'isan' => row_data[21],
'customer_price' => row_data[22],
'apple_identifier' => row_data[23],
'cma' => row_data[24],
'asset_content_flavor' => row_data[25],
'vendor_order_code' => full,
'vendor_order_code_UPC' => upc,
'vendor_order_code_ISRC' => isrc,
'grid' => row_data[27],
'promo_code' => row_data[28],
'parent_identifier' => row_data[29]
)
new_record.save
end
You can try:
'vendor_order_code' => row_data[26],
'vendor_order_code_UPC' => row_data[26].split("_").first
'vendor_order_code_ISRC' => row_data[26].split("_").last if row_data[26].match(/_/)

Resources