I have no idea why, but the error just disappear without any changes. Now it works. I have not change anything. (I deleted cache many times so it cannot be because of the cache)
Problem
I created an extension using extension builder (if anyone knows any good documentation please give me link because official documentation does not have any examples).
I have a form and when I submit the form I have the error
TYPO3 v4.7
The action "formSave" (controller "Promoters") is not allowed by this plugin. Please check Tx_Extbase_Utility_Extension::configurePlugin() in your ext_localconf.php.
I created ext_localconf.php according to typo's wiki.
Form code
<f:form action="formSave" name="" object="">
<f:form.textfield id="emailResendInterval" name="emailResendInterval" value="" />
<f:form.textarea cols="30" rows="5" id="emails" name="emails" value="" />
<f:form.submit name="submit" value="Save" />
</f:form>
ext_localconf.php
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY] = unserialize($_EXTCONF);
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['registerSinglePlugin']) {
// fully fletged blog
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY, // The extension name (in UpperCamelCase) or the extension key (in lower_underscore)
'Promoters', // A unique name of the plugin in UpperCamelCase
array ( // An array holding the controller-action-combinations that are accessible
'Promoters' => 'configuration,formSave', // The first controller and its first action will be the default
),
array( // An array of non-cachable controller-action-combinations (they must already be enabled)
)
);
} else {
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY, // The extension name (in UpperCamelCase) or the extension key (in lower_underscore)
'Promoters', // A unique name of the plugin in UpperCamelCase
array ( // An array holding the controller-action-combinations that are accessible
'Promoters' => 'configuration,formSave', // The first controller and its first action will be the default
),
array( // An array of non-cachable controller-action-combinations (they must already be enabled)
)
);
PromotersControler
class Tx_Promoters_Controller_PromotersController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* action configuration
*
* #return void
*/
public function configurationAction() {
}
/**
* action formSave
*
* #return void
*/
public function formSaveAction() {
}
}
Seems fine actually, I'm not sure about the if statemant in the localconf though. Please try this:
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');
// fully fletged blog
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY,
'Promoters',
array (
'Promoters' => 'configuration,formSave',
),
array(
)
);
?>
Related
I am using TYPO3 10.4.15
My edit view:
f:section name="content">
<h1>Edit Album</h1>
<f:flashMessages />
<f:render partial="FormErrors" />
<f:form id='fNew' action="update" name="album" object="{album}" arguments="{mode:mode, disc:disc}" >
<f:render partial="Album/FormFields" arguments="{album:album, disc:disc}" />
<f:form.submit value="Save" />
</f:form>
</f:section>
</html>
This is the relevant part of the partial formfields.html:
<f:if condition='{disc}'>
<input type='text' name="disc[0][name][]" />
</f:if>
The error_log with the disc structure looks:
Update-Disc: array (
0 =>
array (
'name' => '',
'trackNum' => '1',
'track' =>
array (
0 =>
array (
'title' => '',
'duration' => '0',
'composer' => '',
'texter' => '',
'musicFile' => '',
'imageFile' => '',
),
),
),
)
And this is the "updateAction" part of the controller
/**
* action update
*
* #param \HGA\Album\Domain\Model\Album $album
* #param string $mode
* #param array $disc
* #return string|object|null|void
*/
public function updateAction(\HGA\Album\Domain\Model\Album $album, $mode, $disc)
{
error_log("Update-Disc: " . var_export($disc, true) . " Mode: " . $mode, 0);
if ($mode == 'tracks') {
$this->editAction($album, $mode, $disc);
}
error_log("Update: " . var_export($album, true) . " Mode: " . $mode, 0);
$this->addFlashMessage('The object was updated. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING);
$this->albumRepository->update($album);
$this->redirect('list');
}
If I write something into the text input field and execute submit, I get the error_log you can see above. The value I have typed in the input field is missing. It is only the array, as I have send it to the view.
The mode string will be transmitted correctly, but with the disc array is maybe something wrong!
The disc array is more complex, but I made it simple, because I need to understand how it works in general.
I also need this additional disc array and can not doing it with the album object!
Thanks in advance for your help.
You are ignoring your plugin's namespace in combination with misinterpretation of f:form arguments.
Each field for your plugin has a prefix like tx_hgaalbum... followed by your property's name in square brackets. So the fieldname for disc should look like tx_hgaalbum...[disc]. Have a look into the HTML code and see which names are generated for the other properties.
The second problem is using the arguments in the form-ViewHelper. This will only add the arguments to the action URI of your form. That's why you're getting your initial values for disc.
I recently set up the ability to tag posts on my site. I had everything working fine. Then as I was wrapping up I tested all my admin side forms again. The Add Tag form no longer does anything. It doesn't even flash an error or redirect after submission. The page just reloads at the same URL. The only changes to the site I have made since initial testing was move the forms to the admin side of the dev site. Here is some code to hopefully reveal what the mystery is. Also my edit tag form is doing similar thing. It has no flash message but redirects back to the index, like its supposed to but with no changes made to the tag. Ill include the edit code as well.
Add.ctp in src/Template/Admin/Tags/Add.ctp
<div class="tags form large-9 medium-8 columns content">
<?= $this->Form->create($tag) ?>
<div class="form-group">
<fieldset>
<h1 class="page-header">New Tag</h1>
<?php
echo $this->Form->input('name', ['class' => 'form-control']);
?>
</fieldset>
</div>
<?= $this->Form->button(__('Submit'), ['class' => 'btn btn-primary']) ?>
<?= $this->Form->end() ?>
</div>
Here is my Add funciton in my TagsController:
public function add()
{
$this->viewBuilder()->layout('admin');
$tag = $this->Tags->newEntity();
if ($this->request->is('post')) {
$tag = $this->Tags->patchEntity($tag, $this->request->data);
if ($this->Tags->save($tag)) {
$this->Flash->success(__('The tag has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The tag could not be saved. Please, try again.'));
}
$this->set(compact('tag'));
$this->set('_serialize', ['tag']);
}
Here is my Edit funciton in my TagsController:
public function edit($id = null)
{
$this->viewBuilder()->layout('admin');
$tag = $this->Tags->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$tag = $this->Tags->patchEntity($tag, $this->request->data);
if ($this->Tags->save($tag)) {
$this->Flash->success(__('The tag has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The tag could not be saved. Please, try again.'));
}
$this->set(compact('tag'));
$this->set('_serialize', ['tag']);
}
Edit.ctp in src/Template/Admin/Tags/Edit.ctp
<div class="tags form large-9 medium-8 columns content">
<?= $this->Form->create($tag) ?>
<div class="form-group">
<fieldset>
<h1 class="page-header">Edit Tag</h1>
<?php
echo $this->Form->input('name', array('class' => 'form-control'));
?>
</fieldset>
</div>
<?= $this->Form->button(__('Submit'), ['class' => 'btn btn-primary']) ?>
<?= $this->Form->end() ?>
</div>
Just as a side note. I started getting errors when creating a new post as well.
General error: 1364 Field 'section_id' doesn't have a default value
I did go into my DB and give the field a default value. But then when I fill out the form for a new post again, the error just moves to the next table column. I am assuming they are some how related since they popped up at the same time and because tags and posts are related to each other.
TagsTable:
class TagsTable extends Table
{
/**
* Initialize method
*
* #param array $config The configuration for the Table.
* #return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->table('tags');
$this->displayField('name');
$this->primaryKey('id');
$this->hasMany('PostsTags', [
'foreignKey' => 'tag_id'
]);
}
/**
* Default validation rules.
*
* #param \Cake\Validation\Validator $validator Validator instance.
* #return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->integer('id')
->allowEmpty('id', 'create');
$validator
->requirePresence('name', 'create')
->notEmpty('name');
return $validator;
}
}
Tags Entity:
class Tag extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* #var array
*/
protected $_accessible = [
'*' => false,
'id' => false
];
}
When I place <?php debug($tag); ?> into my add.ctp view this is the out put it gives me:
object(App\Model\Entity\Tag) {
'[new]' => true,
'[accessible]' => [],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Tags'
}
Again, in question always post debug pathEntity output, in your case debug($tag), also Tag Entity, your validation code, and how looks your db tags table.
Answer:
General error: 1364 Field 'section_id' doesn't have a default value
This means that you have not passed a value for this field.
You can change that table field to accept null or empty value and/or set default if not passed from application, or make validation in your TagsTable to be sure if submitted data valid before send to db.
After question updated:
protected $_accessible = [
'*' => false, <---- should be true
'id' => false
];
This means that all fields except id are accessible
Good afternoon, dear friends! All, I give up. Tried well, all that was already possible. TYPO3 7.6.16
ext_tables.php:
<?php
if (!defined('TYPO3_MODE')) die ('Access denied.');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'MyVendor.' . $_EXTKEY,
'Pi1',
'The inventory list'
);
ext_localconf.php:
<?php
if (!defined('TYPO3_MODE')) die ('Access denied.');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'MyVendor.' . $_EXTKEY,
'Pi1',
Array ('Comment' => 'list'),
Array ('Comment' => 'list')
);
And constantly the same mistake
The default controller for extension "Fecomments" and plugin "Pi1" can not be determined
I read topics with same error but nothing help me.
I already climbed into the kernel, found out that $configuration ['controllerConfiguration'] is an empty array, I do not know why data does not arrive there. Comrades, help me out, I do not know what to do, honestly! )
At first, use the correct syntax for the two files. Examples:
ext_tables.php:
<?php
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function($extKey)
{
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'VENDOR.Extensionkey',
'Pi1',
'Extension Display Name'
);
},
$_EXTKEY
);
ext_localconf.php:
<?php
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function($extKey)
{
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'VENDOR.' . $extKey,
'Pi1',
[
'First' => 'action1, action2'
],
// non-cacheable actions
[
'First' => ''
]
);
},
$_EXTKEY
);
The make sure the namespace and class name are fine:
typo3conf/ext/extensionkey/Classes/Controller/FirstController.php:
/***
*
* This file is part of the "extensionkey" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2017
*
***/
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* FilecollectorController
*/
class FirstController extends ActionController
{
/**
* action1
*
* #return void
*/
public function action1Action()
{
}
/**
* action1
*
* #return void
*/
public function action2Action()
{
}
}
Clear all caches. Sometimes it will help to go into ExtensionManager and disable/enable the whole extension. In case of changed classnames or changes in the tables/localconf files, this will flush ALL caches.
The solution provided by Mikael is not available at the moment.
Short version of the external website, that is currently offline:
Try to delete and recreate the content element on your page to delete old flexform values
I have a custom module called "visionart cart" working as expected and have enabled a page through hook_menu();
function visionart_cart_menu(){
/**
* Implements hook_menu()
*/
$items['build-order'] = array (
'title' => 'Build your order',
'menu_name' => 'main-menu',
'type' => MENU_NORMAL_ITEM,
'page callback' => 'visionart_cart_build_order',
'access arguments' => array ('access content'),
'access callback' => 'user_is_logged_in',
);
}
Page callback returns the template page, everything works:
function visionart_cart_build_order() {
return theme('build_order_template');
}
/** Implements hook_theme. */
function visionart_cart_theme() {
return array (
'build_order_template' => array (
'template' => 'build_order'
)
);
}
In build_order.tpl.php, I've added a bunch of custom HTML show up on the build_order.php page. Everything renders fine. But I'd like to add user autocomplete functionality to the input field that is created on this build_order.tpl.php file.
<li class="my-custom-item">
<input type="text" name="build_order_username" value="" />
</li>
How and where do I do that? I've seen how to create form fields programmatically through Drupal's form building functions, but i can't find where to indicate to Drupal that this custom created input should use autocomplete on the user base. Thanks!
You will require an API endpoint call, which will auto-complete the fields. Assuming you are on Drupal 7, here is a link from the official Drupal documentation on how to make autocomplete fields.
I have a relation ManyToOne between two entities Articles.php and Corrections.php.
Look at this code, Corrections.php where my FK constraint is:
class Corrections
{
/**
* #var \Articles
*
* #ORM\ManyToOne(targetEntity="Articles")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="article_id", referencedColumnName="id")
* })
*/
private $article;
An article could have many correction, but a correction belong to only one article.
So, in my Corrections.php, I have the foreign key named $article refers to article_id in MySQL database.
Now I need to add a correction to an article in a form Type, but not only that.
This is the controller code for:
public function addCorrectionAction() {
$em=$this->getDoctrine()->getManager();
$correction= new Corrections;
$form = $this->createForm(new CorrectionsType(), $correction);
$request = $this->getRequest();
if ($request->isMethod('POST') | ($form->isValid()) ) {
$form->bind($request);
$correction= $form->getData();
$em->persist($correction);
$em->flush();
return $this->redirect($this->generateUrl('indexArticles'));
}
else {
return $this->render('Bundle:Folder:addCorrections.html.twig', array('form' => $form->createView() ));
}
}
No problems here for now. This my buildForm, CorrectionsType.php:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name')
->add('date')
->add('description')
->add('text')
->add('articles', 'collection', array(
'type' => new ArticlesType(),
'allow_add' => true))
;
}
And the twig view:
<form action="{{ path('addCorrection_process') }}" method="POST">
{{ form_widget(form) }}
<div class="row col-md-3">
<input type="submit" value="Add correction and article" class="btn"/>
</div>
</form>
In fact, I need to create a form which allows a user to add an article and his correction at the same time. Or here, when I display the addCorrection method with the form, the field articles is a select which allow user to add a correction to an existing article.
How can I proceed to have a form which allow user correctly ADD a NEW correction and a NEW article at the time in the same form? I need this form must be consistent with my FK constraint too, i-e when I ADD a NEW correction with a NEW article at the same time, the FK $article (article_id) have the correct value refers to the correction_id.
Check Collection Field Type official documentation page. So basically you create ArticleType and CorrectionType forms and connect the latter by collection field type.