<p>I have defined string and mixed attributes for my Record/Model.</p>

<pre><code>'titel' =&gt; array(AttributeType::String),
'lage' =&gt; array(AttributeType::Mixed, 'required' =&gt; true),
</code></pre>

<p>If i try to save a record, the data will not be saved, if required=true is not defined! That happens with both, string and mixed attribute types.</p>

<p>But i want to save the records also with empty values.
Whats wrong?</p>

<p>// UPDATE:</p>

<p>I found this <a href="https://craftcms.stackexchange.com/questions/8246/the-active-record">The Active Record</a> and added this to my model</p>

<pre><code>public function rules(){
    return array(
        array('title', 'default', 'setOnEmpty' =&gt; true, 'value' =&gt; null),
    );
}
</code></pre>

<p>But it doesnt change anything.</p>

CC BY-SA 3.0
2015-03-27T19:59:20.807Z
After you call `$yourRecord->save()`, does `$yourRecord->getErrors()` return anything?
Brad Bell
CC BY-SA 3.0
2015-03-28T10:34:01.737Z
No, no errors at all. The log file shows that db Commands will be executed and the relevant values are definitely null. As soon as i change 'required' to true, the same values will be saved.
phaetons
CC BY-SA 3.0
2017-09-28T19:23:47.847Z
There is something critically wrong with Craft here.  Amateur hour.
Tyguy7
<plugins><records><attribute>
Record - Mixed/String values will not be saved if attribute not required=true
# Record - Mixed/String values will not be saved if attribute not required=true

(Asked by: username_0 on 2015-03-27)

I have defined string and mixed attributes for my Record/Model.
'titel' => array(AttributeType::String),
'lage' => array(AttributeType::Mixed, 'required' => true),

If i try to save a record, the data will not be saved, if required=true is not defined! That happens with both, string and mixed attribute types.
But i want to save the records also with empty values.
Whats wrong?
// UPDATE:
I found this The Active Record and added this to my model
public function rules(){
    return array(
        array('title', 'default', 'setOnEmpty' => true, 'value' => null),
    );
}

But it doesnt change anything.

**Tags:** plugins, records, attribute

> **Comments:**
> **username_1**: After you call `$yourRecord->save()`, does `$yourRecord->getErrors()` return anything?  
> **username_0**: No, no errors at all. The log file shows that db Commands will be executed and the relevant values are definitely null. As soon as i change 'required' to true, the same values will be saved.  
> **username_2**: There is something critically wrong with Craft here.  Amateur hour.  

---

## 0 answers

