Hi all
I’m trying to add an extension setting textarea field but all I can get it to do is display it as a text input. Here’s the code:
$this->settings = array(
'api_email' => '',
'api_password' => '',
'email_for_notification' => $this->EE->config->item('webmaster_email'),
'trigger_field' => '',
'trigger_value' => 'y',
'sms_number_field' => '',
'html_email_content' => array('t', 't', ''),
'text_email_content' => array('t', 't', '')
)The two fields at the bottom are the ones I’m struggling with - they should be textarea fields that accept a string and default to an empty string. When viewing the extension settings, I see a text input instead of a textarea with the default value of ‘Array’.
Where have I gone wrong there?
Also I am finding I need to click on the Enable link twice in the Add-ons > Extensions screen before the extension shows as being enabled. Any ideas what that might be?
Thanks
[Mod Edit: Moved to the Development and Programming forum]
Hi Erik
Here’s the settings method:
function settings()
{
$settings = array();
$settings['api_email'] = '';
$settings['api_password'] = '';
$settings['email_for_notification'] = $this->EE->config->item('webmaster_email');
$settings['trigger_value'] = 'y';
$settings['html_email_content'] = '';
$settings['text_email_content'] = '';
$freeform_fields = $this->_get_freeform_fields();
$member_fields = $this->_get_member_fields();
if (sizeof($freeform_fields) > 0)
{
$settings['trigger_field'] = array('s', $freeform_fields);
}
if (sizeof($member_fields) > 0)
{
$settings['sms_number_field'] = array('s', $member_fields);
}
return $settings;
}The _get_freeform_fields() and _get_member_fields() are private methods that return an array of field labels and names so that the user can select a relevant field from the database.
And my activate method:
<pre><code>function activate_extension() { $this->settings = array( ‘api_email’ => ”, ‘api_password’ => ”, ‘email_for_notification’ => $this->EE->config->item(‘webmaster_email’), ‘trigger_field’ => ”, ‘trigger_value’ => ‘y’, ‘sms_number_field’ => ”, ‘html_email_content’ => array(‘t’, ‘t’, ”), ‘text_email_content’ => array(‘t’, ‘t’, ”) );
$hooks = array(
array(
'hook' => 'freeform_module_insert_begin',
'method' => 'freeform_module_insert_begin',
'priority' => 10
)
);
foreach ($hooks AS $hook)
{
$this->EE->db->insert(
'extensions',
array(
'class' => __CLASS__,
'enabled' => 'n',
'hook' => $hook['hook'],
'method' => $hook['method'],
'priority' => $hook['priority'],
'settings' => serialize($this->settings),
'version' => $this->version
)
);
}
}[/code]
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.