Why can't magento accept `content` as a database field name?

I am creating a new module and in that module I add a form which has a field name content in the database.

Now when I add a wyswig editor in this form with the field name content in the database, the layout of the form in the backend changes completely as compared to default layout.

But when I changed the database field name from content to any other name lets say content_html or content_h etc etc., the layout of the form now appeared as a default form.

This happens only when I use wyswig editor, and without wyswig if I create simple form it accepts the values in the database under the content field name.

Why can't magento accept the content as a field name, using wyswig editor.

Solutions

Just so this will have an answer.... Based on the post mentioned in the comments.

You cannot have a field named content because, in this case magento creates the following textarea

<textarea name="content" id="content"...></textarea>

Now comes the tinymce js that tries to turn your textarea into a WYSIWYG editor. It looks for the element with id content, but this element already exists higher in the DOM.

<div class="main-col" id="content">

This causes an malfunction.

So basically the problem is not that your element (or table column) has the name content. The problem is that the id of the element is content.

Magento actually has an entity with a field name content and works just fine. It is Cms page entity.

Take a look at Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Content::_prepareForm. You will see this:

$contentField = $fieldset->addField('content', 'editor', array(
    'name'      => 'content',
    'style'     => 'height:36em;',
    'required'  => true,
    'disabled'  => $isElementDisabled,
    'config'    => $wysiwygConfig
));

The solution is to have a different id for the textarea.
In order to achieve this you can use

$form->setHtmlIdPrefix('some_prefix_');

This transforms all the ids for the elements in the form from elemId to some_prefix_ememId.

In your case content becomes some_prefix_content and everything should work.

Similar questions

Checkout - Accept email id in login.phtml step of one page magento checkout
During the checkout process, in billing.phtml the following submit code accepts the various inputs given by the user It specifically looks like the onclick="billing.save()" causes the entries to be processed. How do i modify the above to accept email id in the previous login.phtml step of the one page checkout process ?
Any type of email is not working accept forgot password in magento
In my magento store any type of email is not send/working only if I do change user password from admin then it's send mail to particular user that your password is changed otherwise not any mail being send. for double check that if php mail function is working or not I have create one mail.php file in my root directory and below is my mail.php code...
Magento 2.1: Do we need to do anything special for the controll action to accept HTTP Post with Json Payload?
I have a controller action that will be used for webhook handler. When I did the form post to that URL with header content-type: application/x-www-form-urlencoded My load is: MyVariableOne=ValueOne&MyVariableTwo=ValueTwo On the action's execute function, I had $data as $data = $this->getRequest()->getPostValue(); When I do var_dump, I got: arra...
Magento 1.9 Suddenly will not accept an SKU starting with a letter
I'm currently running a staging copy of a live Magento 1.9 site. On this staging site I have noticed that if I attempt to add a new product with an SKU that begins with a letter (character between A-Z) (e.g. HOS2019), I get an error of Please enter a valid number in this field. If I begin the SKU with a number, the product is accepted and saved wit...
Does magento 2.3.3 accept external image server?
After successfully completed data migration, extra slash added on image url if image get from other server. Note : If url like this -> magento1.com/media/catalog/product/2/9/29594114-1.jpg instead of magento1.com/media/catalog/product\cache\f2b44f5a43f5823dafd935ad802e62ad/2/9/29594114-1.jpg image visible.
Accept product feed into magento via api (XML)
Is it possible to receive a product feed via external api? I've looked at the magento api and I can see how to produce an XML web service to feed products out, but I need to feed information into magento. I have a supplier of products with an XML api (SOAP). Is it possible to connect my magento store to this api?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.