Change name of yiiimperaviWidget widget
I want to change the name of the form field from Page[body] to body lets say. Following is the code for WYSIWYG editor.
<?php echo $form->field($model, 'body')->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
I don't want to change my model just the name of the form field submitted as the filed is submitted to remote API.
For normal fields i do <?php echo $form->field($model, 'name')->textInput(['name' => 'name']) ?>
yii2
add a comment |
I want to change the name of the form field from Page[body] to body lets say. Following is the code for WYSIWYG editor.
<?php echo $form->field($model, 'body')->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
I don't want to change my model just the name of the form field submitted as the filed is submitted to remote API.
For normal fields i do <?php echo $form->field($model, 'name')->textInput(['name' => 'name']) ?>
yii2
are you saying that you dont want the name for the textarea that is generated by the widget to include model name?, if you dont want the model name to be the part of the fieldname
then use the widget without the model instance see here OR you can use aFormModel
and declare your desired field names and use that formModel to create the ActiveForm
– Muhammad Omer Aslam
Nov 25 '18 at 13:15
@MuhammadOmerAslam yes It can be done that way but I don't want to change my model. Isn't there a way to change the ID and NAME of the field without going for a work around?
– Fareed Ud Din
Nov 25 '18 at 19:17
add a comment |
I want to change the name of the form field from Page[body] to body lets say. Following is the code for WYSIWYG editor.
<?php echo $form->field($model, 'body')->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
I don't want to change my model just the name of the form field submitted as the filed is submitted to remote API.
For normal fields i do <?php echo $form->field($model, 'name')->textInput(['name' => 'name']) ?>
yii2
I want to change the name of the form field from Page[body] to body lets say. Following is the code for WYSIWYG editor.
<?php echo $form->field($model, 'body')->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
I don't want to change my model just the name of the form field submitted as the filed is submitted to remote API.
For normal fields i do <?php echo $form->field($model, 'name')->textInput(['name' => 'name']) ?>
yii2
yii2
asked Nov 25 '18 at 12:02
Fareed Ud DinFareed Ud Din
46528
46528
are you saying that you dont want the name for the textarea that is generated by the widget to include model name?, if you dont want the model name to be the part of the fieldname
then use the widget without the model instance see here OR you can use aFormModel
and declare your desired field names and use that formModel to create the ActiveForm
– Muhammad Omer Aslam
Nov 25 '18 at 13:15
@MuhammadOmerAslam yes It can be done that way but I don't want to change my model. Isn't there a way to change the ID and NAME of the field without going for a work around?
– Fareed Ud Din
Nov 25 '18 at 19:17
add a comment |
are you saying that you dont want the name for the textarea that is generated by the widget to include model name?, if you dont want the model name to be the part of the fieldname
then use the widget without the model instance see here OR you can use aFormModel
and declare your desired field names and use that formModel to create the ActiveForm
– Muhammad Omer Aslam
Nov 25 '18 at 13:15
@MuhammadOmerAslam yes It can be done that way but I don't want to change my model. Isn't there a way to change the ID and NAME of the field without going for a work around?
– Fareed Ud Din
Nov 25 '18 at 19:17
are you saying that you dont want the name for the textarea that is generated by the widget to include model name?, if you dont want the model name to be the part of the field
name
then use the widget without the model instance see here OR you can use a FormModel
and declare your desired field names and use that formModel to create the ActiveForm– Muhammad Omer Aslam
Nov 25 '18 at 13:15
are you saying that you dont want the name for the textarea that is generated by the widget to include model name?, if you dont want the model name to be the part of the field
name
then use the widget without the model instance see here OR you can use a FormModel
and declare your desired field names and use that formModel to create the ActiveForm– Muhammad Omer Aslam
Nov 25 '18 at 13:15
@MuhammadOmerAslam yes It can be done that way but I don't want to change my model. Isn't there a way to change the ID and NAME of the field without going for a work around?
– Fareed Ud Din
Nov 25 '18 at 19:17
@MuhammadOmerAslam yes It can be done that way but I don't want to change my model. Isn't there a way to change the ID and NAME of the field without going for a work around?
– Fareed Ud Din
Nov 25 '18 at 19:17
add a comment |
2 Answers
2
active
oldest
votes
In the options you could assign an your name value
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'your_name']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
tried that, It should be that simple but the form submits as Page[body]: <p>abc</p>
– Fareed Ud Din
Nov 25 '18 at 12:09
I am submitting the form after serializing. Don't know what I miss here. :/
– Fareed Ud Din
Nov 25 '18 at 12:10
your comment is not clear ..
– scaisEdge
Nov 25 '18 at 12:11
Sorry let me explain. I did what you suggested already but It doesn't change the name of the field. Even after doing what you suggested. <textarea id="w0" name="Page[body]" dir="ltr" style="display: none;"> is the html generated.
– Fareed Ud Din
Nov 25 '18 at 12:15
@FareedUdDin answer updated assigning name the active field and not to the widget
– scaisEdge
Nov 25 '18 at 14:09
|
show 2 more comments
Thank you guys this worked.
<?php
echo yiiimperaviWidget::widget([
// You can either use it for model attribute
'model' => $model,
'attribute' => 'body',
// or just for input field
//'name' => 'body',
'htmlOptions'=>[
'name'=>'body',
],
// Some options, see http://imperavi.com/redactor/docs/
'options' => [
'toolbar' => false,
],
]);
?>
and this also
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'body']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'htmlOptions'=>['name'=>'body'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]);?>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467232%2fchange-name-of-yii-imperavi-widget-widget%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In the options you could assign an your name value
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'your_name']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
tried that, It should be that simple but the form submits as Page[body]: <p>abc</p>
– Fareed Ud Din
Nov 25 '18 at 12:09
I am submitting the form after serializing. Don't know what I miss here. :/
– Fareed Ud Din
Nov 25 '18 at 12:10
your comment is not clear ..
– scaisEdge
Nov 25 '18 at 12:11
Sorry let me explain. I did what you suggested already but It doesn't change the name of the field. Even after doing what you suggested. <textarea id="w0" name="Page[body]" dir="ltr" style="display: none;"> is the html generated.
– Fareed Ud Din
Nov 25 '18 at 12:15
@FareedUdDin answer updated assigning name the active field and not to the widget
– scaisEdge
Nov 25 '18 at 14:09
|
show 2 more comments
In the options you could assign an your name value
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'your_name']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
tried that, It should be that simple but the form submits as Page[body]: <p>abc</p>
– Fareed Ud Din
Nov 25 '18 at 12:09
I am submitting the form after serializing. Don't know what I miss here. :/
– Fareed Ud Din
Nov 25 '18 at 12:10
your comment is not clear ..
– scaisEdge
Nov 25 '18 at 12:11
Sorry let me explain. I did what you suggested already but It doesn't change the name of the field. Even after doing what you suggested. <textarea id="w0" name="Page[body]" dir="ltr" style="display: none;"> is the html generated.
– Fareed Ud Din
Nov 25 '18 at 12:15
@FareedUdDin answer updated assigning name the active field and not to the widget
– scaisEdge
Nov 25 '18 at 14:09
|
show 2 more comments
In the options you could assign an your name value
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'your_name']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
In the options you could assign an your name value
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'your_name']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]
) ?>
edited Nov 25 '18 at 14:08
answered Nov 25 '18 at 12:07
scaisEdgescaisEdge
95.3k105071
95.3k105071
tried that, It should be that simple but the form submits as Page[body]: <p>abc</p>
– Fareed Ud Din
Nov 25 '18 at 12:09
I am submitting the form after serializing. Don't know what I miss here. :/
– Fareed Ud Din
Nov 25 '18 at 12:10
your comment is not clear ..
– scaisEdge
Nov 25 '18 at 12:11
Sorry let me explain. I did what you suggested already but It doesn't change the name of the field. Even after doing what you suggested. <textarea id="w0" name="Page[body]" dir="ltr" style="display: none;"> is the html generated.
– Fareed Ud Din
Nov 25 '18 at 12:15
@FareedUdDin answer updated assigning name the active field and not to the widget
– scaisEdge
Nov 25 '18 at 14:09
|
show 2 more comments
tried that, It should be that simple but the form submits as Page[body]: <p>abc</p>
– Fareed Ud Din
Nov 25 '18 at 12:09
I am submitting the form after serializing. Don't know what I miss here. :/
– Fareed Ud Din
Nov 25 '18 at 12:10
your comment is not clear ..
– scaisEdge
Nov 25 '18 at 12:11
Sorry let me explain. I did what you suggested already but It doesn't change the name of the field. Even after doing what you suggested. <textarea id="w0" name="Page[body]" dir="ltr" style="display: none;"> is the html generated.
– Fareed Ud Din
Nov 25 '18 at 12:15
@FareedUdDin answer updated assigning name the active field and not to the widget
– scaisEdge
Nov 25 '18 at 14:09
tried that, It should be that simple but the form submits as Page[body]: <p>abc</p>
– Fareed Ud Din
Nov 25 '18 at 12:09
tried that, It should be that simple but the form submits as Page[body]: <p>abc</p>
– Fareed Ud Din
Nov 25 '18 at 12:09
I am submitting the form after serializing. Don't know what I miss here. :/
– Fareed Ud Din
Nov 25 '18 at 12:10
I am submitting the form after serializing. Don't know what I miss here. :/
– Fareed Ud Din
Nov 25 '18 at 12:10
your comment is not clear ..
– scaisEdge
Nov 25 '18 at 12:11
your comment is not clear ..
– scaisEdge
Nov 25 '18 at 12:11
Sorry let me explain. I did what you suggested already but It doesn't change the name of the field. Even after doing what you suggested. <textarea id="w0" name="Page[body]" dir="ltr" style="display: none;"> is the html generated.
– Fareed Ud Din
Nov 25 '18 at 12:15
Sorry let me explain. I did what you suggested already but It doesn't change the name of the field. Even after doing what you suggested. <textarea id="w0" name="Page[body]" dir="ltr" style="display: none;"> is the html generated.
– Fareed Ud Din
Nov 25 '18 at 12:15
@FareedUdDin answer updated assigning name the active field and not to the widget
– scaisEdge
Nov 25 '18 at 14:09
@FareedUdDin answer updated assigning name the active field and not to the widget
– scaisEdge
Nov 25 '18 at 14:09
|
show 2 more comments
Thank you guys this worked.
<?php
echo yiiimperaviWidget::widget([
// You can either use it for model attribute
'model' => $model,
'attribute' => 'body',
// or just for input field
//'name' => 'body',
'htmlOptions'=>[
'name'=>'body',
],
// Some options, see http://imperavi.com/redactor/docs/
'options' => [
'toolbar' => false,
],
]);
?>
and this also
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'body']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'htmlOptions'=>['name'=>'body'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]);?>
add a comment |
Thank you guys this worked.
<?php
echo yiiimperaviWidget::widget([
// You can either use it for model attribute
'model' => $model,
'attribute' => 'body',
// or just for input field
//'name' => 'body',
'htmlOptions'=>[
'name'=>'body',
],
// Some options, see http://imperavi.com/redactor/docs/
'options' => [
'toolbar' => false,
],
]);
?>
and this also
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'body']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'htmlOptions'=>['name'=>'body'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]);?>
add a comment |
Thank you guys this worked.
<?php
echo yiiimperaviWidget::widget([
// You can either use it for model attribute
'model' => $model,
'attribute' => 'body',
// or just for input field
//'name' => 'body',
'htmlOptions'=>[
'name'=>'body',
],
// Some options, see http://imperavi.com/redactor/docs/
'options' => [
'toolbar' => false,
],
]);
?>
and this also
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'body']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'htmlOptions'=>['name'=>'body'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]);?>
Thank you guys this worked.
<?php
echo yiiimperaviWidget::widget([
// You can either use it for model attribute
'model' => $model,
'attribute' => 'body',
// or just for input field
//'name' => 'body',
'htmlOptions'=>[
'name'=>'body',
],
// Some options, see http://imperavi.com/redactor/docs/
'options' => [
'toolbar' => false,
],
]);
?>
and this also
<?php echo $form->field($model, 'body',
[ 'options' => [ 'name' => 'body']])->widget(
yiiimperaviWidget::className(),
[
'plugins' => ['fontcolor', 'video'],
'htmlOptions'=>['name'=>'body'],
'options'=>[
'minHeight'=>400,
'maxHeight'=>400,
'buttonSource'=>true,
//'imageUpload'=>Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])
]
]);?>
answered Nov 25 '18 at 19:44
Fareed Ud DinFareed Ud Din
46528
46528
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467232%2fchange-name-of-yii-imperavi-widget-widget%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
are you saying that you dont want the name for the textarea that is generated by the widget to include model name?, if you dont want the model name to be the part of the field
name
then use the widget without the model instance see here OR you can use aFormModel
and declare your desired field names and use that formModel to create the ActiveForm– Muhammad Omer Aslam
Nov 25 '18 at 13:15
@MuhammadOmerAslam yes It can be done that way but I don't want to change my model. Isn't there a way to change the ID and NAME of the field without going for a work around?
– Fareed Ud Din
Nov 25 '18 at 19:17