Whole day I have been working on this trouble but could not find needed information. Okay, I need adding new fields in the ACF group by PHP. I tested function acf_add_local_field. Nothing working. I see that function go to $store->set( $key, $field )->alias( $key, $name );. And everything should be okay but fields not add. Please, help me. How I can add new ACF fields by PHP? Only fields without group. I have needed group.
acf_add_local_field(
array(
'key' => "generalInfo_".$value,
'label' => $value,
'name' => "generalInfo_".$value,
'type' => 'text',
'parent' => 'generalInfo',
'parent_layout' => 'group_6187fed087950',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array('width' => '70')));
}
I add this code to a custom page template.
Related
After I set the 'foreign_sortby' => 'datum'; this field is missing now at my edit mask. Does anybody know why?
TCA of tx_veranstaltungen_domain_model_terminblock (1 terminblock can have multiple termine)
'termine' => array(
'exclude' => 1,
'label' => 'LLL:EXT:veranstaltungen/Resources/Private/Language/locallang_db.xlf:tx_veranstaltungen_domain_model_terminblock.termine',
'config' => array(
'type' => 'inline',
'foreign_table' => 'tx_veranstaltungen_domain_model_termin',
'foreign_field' => 'terminblock',
'foreign_sortby' => 'datum',
'maxitems' => 9999,
'appearance' => array(
'collapseAll' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'useSortable' => 1,
'showAllLocalizationLink' => 1
),
),
),
Okay I found it out whats the problem, after reading Bug report
You should use foreign_default_sortby instead of foreign_sortby, because IRRE hides the field you use for sorting. The dangerous thing is, that the field could be overwritten by "sorting values". So I wondered why all my fields (of type date (timestamp)) has the value 01.01.1970... because the field values changed to 1,2,....
I hope this can help others, before they destroy their data. :)
(I'm using Typo3 7.6.14)
I'm working on a WP Theme that uses Redux Framework and I am trying to create a filter for fields that have a URL attached to them, ie, Background Fields, Media Fields, so that I can make them Protocol relative and able to use SSL site-wide without conflicts.
So far I have the following function in my options-init.php file for a Background Field but to be honest I have very little experience with Filters, and the documentation for Redux Framework is very vague.
Field is as follows:
array(
'id' => 'front-background',
'type' => 'background',
'url' => true,
'title' => __('Front Page Background', 'blanque'),
'desc' => __('Background image for Front Page', 'blanque'),
'subtitle' => __('', 'blanque'),
'compiler' => true,
'output' => array(
'background' => 'body.home',
),
'default' => array(
'url' => '',
),
'background-color' => false,
'preview_height' => '100px',
)
Fuction to filter output:
function the_theme_redux_filters($url) {
$relativeURL = str_replace(array('http://','https://'), '//', $url);
return $relativeURL;
}
add_filter( 'redux/validate/front-background/class/{field.validate}', '', 10, 1 );
Would someone be able to give me a clue as to what I should actually be doing please?
How can i add a new field in prestashop's back office?
Specific, i want to insert a text field in the BO: Orders->Statuses->Add New Order Status under the status name. Which files i have to modify in order to do that? Can anyone describes the full procedure?
Thanks
I am using Prestashop version 1.6.1.2 and added one text field using following steps. You need to make changes in core files. You have to add field in one table in database and do some changes in class and controller file.
Here are the steps to do the same. I have adde field 'my_custom_field'.
Add one field in order_state table
ALTER TABLE {YOUR_DB_PREFIX}order_state ADD my_custom_field VARCHAR(50) NOT NULL;
Change class file of order state. You need to define your field in file "classes/order/OrderState.php"
After code
public $deleted = 0;
add this code snipet
public $my_custom_field;
After code
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
add this code snipet
'my_custom_field' => array('type' => self::TYPE_STRING),
open "controllers/admin/AdminStatusesController.php" file and do following changes
in function initOrderStatutsList()
after this code
'name' => array(
'title' => $this->l('Name'),
'width' => 'auto',
'color' => 'color'
),
add this code
'my_custom_field' => array(
'title' => $this->l('My Custom Field'),
'width' => 'auto',
),
in function renderForm()
after this code
array(
'type' => 'text',
'label' => $this->l('Status name'),
'name' => 'name',
'lang' => true,
'required' => true,
'hint' => array(
$this->l('Order status (e.g. \'Pending\').'),
$this->l('Invalid characters: numbers and').' !<>,;?=+()##"{}_$%:'
)
),
add this code
array(
'type' => 'text',
'label' => $this->l('My Custom field'),
'name' => 'my_custom_field',
),
Do changes suggested here. Hope this helps you :)
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.
I am trying to add a custom input field to the account information tab of a customer in admin. i have successfully been able to create a custom attribute in the eav table for my input, but have been unsuccessful in finding how to make my input show up. curious of anyone has any good resources on how to do this?
The above link doesn't work anymore. I found a better explanation at http://www.excellencemagentoblog.com/customer-registration-fields-magento1-6 . If you just do the first steps you will only have the added fields in the admin.
The fastest way is to create a php file and access it through browser add the following content to file.
define('MAGENTO', realpath(dirname(__FILE__)));
ini_set('memory_limit', '32M');
set_time_limit (0);
require_once MAGENTO . '/../app/Mage.php';
Mage::app();
$newFields = array(
'custom_attribute' => array(
'type' => 'text',
'label' => 'Customer Custom Attribute'
)
);
$entities = array('customer');
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
foreach($newFields as $attributeName => $attributeDefs) {
foreach ($entities as $entity) {
$setup->addAttribute($entity, $attributeName, array(
'position' => 1,
'type' => $attributeDefs['type'],
'label' => $attributeDefs['label'],
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'searchable' => 0,
'filterable' => 0,
'comparable' => 0,
'visible_on_front' => 1,
'visible_in_advanced_search' => 0,
'unique' => 0,
'is_configurable' => 0,
'position' => 1,
));
}
}
You have to tell the attribute which forms it's used in:
Mage::getModel('customer/attribute')
->loadByCode('customer', 'your_attrib_code')
->setUsedInForms(array('adminhtml_customer'))
->save();
This can be put in a standard Magento upgrade script for convenience (usually the same script that originally created the attribute, or the one right after it).