I have another plugin development question.
I am now trying to learn how to work with the database. To that extent, I have the following code:
On the templates/settings.html page I have the following code:
{% import "_includes/forms" as forms %}
{{ forms.radioGroup({
label: "Radio Group Label"|t,
instructions: "Radio Group Instructions"|t,
name: 'radioGroupName',
options:{ "option_1" : "option_1", "option_2" : "option_2"},
value: settings.radioGroupName
}) }}
On the records/PluginNameRecord.php page, I have the following code:
<?php
namespace Craft;
class PluginNameRecord extends BaseRecord
{
public function getTableName()
{
return 'pluginname';
}
public function defineAttributes()
{
return array(
'radioGroupName' => array(AttributeType::String, 'default' => 'option_1')
);
}
}
And here is the code for the models/PluginNameModel.php file (I don't know if this is relevant or not, but I'm including it just in case):
<?php
namespace Craft;
class PluginNameModel extends BaseModel
{
public function defineAttributes()
{
return array(
'radioGroupName' => array(AttributeType::String, 'default' => 'option_1')
);
}
}
Now, I have tested this and it creates a table and column in mysql. However, I cannot update the data in the database. That is to say, if I select option_2 nothing happens in mysql. The same default value of option_1 still shows up.
Can someone please let me know what I am doing wrong?
Thanks,
Moshe