yii2mod / yii2-editable Goto Github PK
View Code? Open in Web Editor NEWEditable widget and column for gridview.
License: MIT License
Editable widget and column for gridview.
License: MIT License
Gridview Update after update select value not working
Hi,
I am really new to Yii2 and I want to understand how I can obtain the DB table key for the value modified. The controller action is receiving the post ok , but I only have the changed variable., not the DB key to modify. How do I do this?
Nick
Hi, I'm trying to use your EditableColumn, but with related model's attribute:
[
'class' => EditableColumn::class,
'attribute' => 'image.alt',
'url' => ['update-related-alt'],
],
Currently your code doesn't allow such use.
I fixed this as follows:
Method run()
:
public function run()
{
$model = $this->findModelOrCreate();
$attribute = $this->getModelAttribute();
if ($this->preProcess && is_callable($this->preProcess, true)) {
call_user_func($this->preProcess, $model);
}
$model->setScenario($this->scenario);
$value = Yii::$app->request->post('value');
$attributeParts = explode('.', $attribute);
$relatedModel = $model;
foreach ($attributeParts as $attributePart) {
$relatedModel = $relatedModel->$attributePart;
}
$relatedModel = $value;
if ($model->validate([$attribute])) {
return $model->save(false);
} else {
throw new BadRequestHttpException($model->getFirstError($attribute));
}
}
And the method getModelAttribute()
:
private function getModelAttribute()
{
$attribute = Yii::$app->request->post('name');
/*if (strpos($attribute, '.')) {
$attributeParts = explode('.', $attribute);
$attribute = array_pop($attributeParts);
}*/
if ($attribute === null) {
throw new BadRequestHttpException('Attribute cannot be empty.');
}
return $attribute;
}
@igor-chepurnoi
How can I add multiple= 'true' in email type. ?
Actually Html5 has multiple attributes to enter multiple email address with validation.
how to set max length for EditableColumn?
Is it support 'file input' type in editable mode?
I have need multi select option on grid inline edit. is there any solution for this?
How to add numeric verification after input, bootstrap-editable plugin has validate method, how to use it in yii2
I install plugin via composer and it install it in bower-asset directory. But try look up in bower directory.
I am getting the following error
Exception 'yii\base\InvalidArgumentException' with message 'Key "id" is not a column name and can not be used as a filter'
\yii2mod\editable\Editable::widget([
'model' => $model,
'type' => 'textarea',
'attribute' => 'note',
'url' => '/profile/update',
]);
CLOSED
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.