11 Yii::import(
'booster.widgets.TbEditable');
43 throw new CException(
'Parameter "model" should be provided for TbEditableField');
46 if (!$this->attribute) {
47 throw new CException(
'Parameter "attribute" should be provided for TbEditableField');
52 $originalText = strlen($this->text) ? $this->text :
CHtml::value($this->model, $this->attribute);
55 if($this->apply ===
false) {
56 $this->text = $originalText;
62 $resolved = $this->
resolveModels($this->model, $this->attribute);
63 $this->model = $resolved[
'model'];
64 $this->attribute = $resolved[
'attribute'];
65 $this->staticModel = $resolved[
'staticModel'];
67 $isMongo = $resolved[
'isMongo'];
68 $isFormModel = $this->model instanceOf CFormModel;
73 $this->text = $originalText;
81 $this->text = $originalText;
87 if ($this->type === null) {
89 if (!$isMongo && !$isFormModel && array_key_exists($this->attribute,
$staticModel->tableSchema->columns)) {
91 if($dbType ==
'date') {
94 if($dbType ==
'datetime') {
95 $this->type =
'datetime';
97 if(stripos($dbType,
'text') !==
false) {
98 $this->type =
'textarea';
104 if(empty($this->name)) {
111 if($pkModel && !$pkModel->isNewRecord) {
112 $this->pk = $pkModel->primaryKey;
116 if(empty($this->send) && empty($this->options[
'send'])) {
117 $this->send =
'always';
128 if (!strlen($this->text) && !$this->_prepareToAutotext) {
129 $this->text = $originalText;
133 if($this->model && $this->_prepareToAutotext) {
138 if ($this->title === null) {
140 'Select' => array(
'select',
'date'),
141 'Check' => array(
'checklist')
143 $title = Yii::t(
'TbEditableField.editable',
'Enter');
144 foreach($titles as $t => $types) {
145 if(in_array($this->type, $types)) {
146 $title = Yii::t(
'TbEditableField.editable', $t);
151 $this->title = strtr($this->title, array(
'{label}' =>
$staticModel->getAttributeLabel($this->attribute)));
155 if($pkModel && !isset($this->params[
'scenario'])) {
156 $this->params[
'scenario'] = $pkModel->getScenario();
175 return in_array(
'EMongoEmbeddedDocument', class_parents(
$model,
false));
191 $len = count($explode);
199 for(
$i = 0;
$i < $len-1;
$i++) {
201 if(
$model->$name instanceof CModel) {
215 $relationName = $explode[$len-2];
216 if(
$model instanceof CActiveRecord) {
217 $className =
$model->getActiveRelation($relationName)->className;
219 $embedded =
$model->embeddedDocuments();
220 if(isset($embedded[$relationName])) {
221 $className = $embedded[$relationName];
223 throw new CException(
'Embedded relation not found');
226 throw new CException(
'Unsupported model class '.$relationName);
239 'isMongo' => $isMongo