6

I believe that setContentFromPost can only be used to set the content of custom fields on an EntryModel, not standard fields such as title. Instead, you need to use $entry->getContent()->title to set the title on the EntryModel. So your code would look like this: $movie = [ 'movieID' => (int)$ctx_movie['MOVIE_ID'], 'audioLanguage' => ...


5

In Craft 3 / Guest Entries 2, you could pull this off without hacking Guest Entries by writing a module that listens to the beforeSaveEntry event, and sets the id on the entry. use Craft; use craft\elements\Entry; use craft\guestentries\controllers\SaveController; use craft\guestentries\events\SaveEvent; use yii\base\Event; use yii\web\...


5

As carlcs said, this is already working as expected. Craft only enforces content validation rules for enabled entries (not including drafts), and most people prefer that behavior. If you want to change that behavior, you can write a plugin that provides its own entry validation logic, by latching onto the entries.onBeforeSaveEntry event. Just put this in ...


4

As other answers have touched on, the behaviour you're seeing is by design. I've written a plugin called Always Validate which will make Craft validate all disabled entries and categories – including entry drafts or entries saved by users not permitted to publish – which should solve your issue.


4

I've figured it out Go to GuestEntriesController.php and add this line of code on the 182nd line $entry->id = craft()->request->getPost('entryId'); Then add an hidden input field with the id you wish to edit like so: <input type="hidden" name="entryId" value="{{ entry.id }}">


4

It turns out the data wasn't being saved as I hadn't set a fieldLayoutId value. Now that I've figured this out, I've written a helper method to make saving any entry type much easier: public static function saveNewEntry(string $handle, array $fields) { $entryType = EntryType::find()->where(['handle' => $handle])->one(); $entry = new ...


4

I don't know the specific rules Craft uses but I believe Craft auto appends the -1 when it tries to save an Element that has a matching URI in the craft_elements_i18n table. A few scenarios that I can think of that may behave like you describe: Somehow, there is an existing record in your database that matches the URI of your Entry using the cics-west-...


4

I think the answer is as simple as providing the new Entry's URI to the redirectInput function: <form method="POST"> {{ actionInput('entries/save-entry') }} {{ redirectInput('{uri}') }} <input type="text" name="title"> <button>Save!</button> </form> Craft looks at the string you pass in, ...


3

Is it possible to have the Japanese and English version disabled by default? Yes. Visit Settings -> Sections -> [Your Section Name] inside the Control Panel. Under the heading Which locales should entries in this section target? there's a Default Entry Status Lightswitch for each locale. Make sure the Lightswitches are off (i.e., not green) for the English ...


3

You can connect to your database and run: SELECT * FROM craft_elements_i18n WHERE slug = 'forms'; to see what other element is already using the slug forms. To see what type of element it is (Entry, Asset, etc.), cross reference the elementId column of the result with the id column in the craft_elements table.


3

That's the idea behind Drafts, to store entries not yet ready to publish, unfinished ones so to speak. I think it does make sense to not validate the fields. Good feature!


3

I ran into this a while ago and it drove me nuts. Try adding disabled and selected attributes to your initial option in the select. So in your case <option disabled selected>---</option>.


3

Something on the $entryToSave EntryModel is failing validation. If you echo out implode(', ', $entryToSave()->getAllErrors());, then you'll see what those errors are and you can correct them.


3

Your script probably chokes because you're interacting with an undeclared variable $params – i.e. change if($params['isNewEntry']) { to if($event->params['isNewEntry']) {


2

That would be the same behavior for using {id} in the title format for new entries created in the control panel as well. The problem with {id} is that's not known until the entry is already saved to the database since it's a database generated number. That's why it's empty for new entries but re-saving the entry will cause it to appear. The easiest thing ...


2

My mistake... I had {parent.ui} as the nested entry slug for the section. {parent.uri} is correct.


2

You can't just append rows to an existing table field from a form. The controller expects the complete data set, so you'd need to query for the existing rows in your template and post them together with the new rows for that field.


2

There isn't an "event" that gets fired when an entry goes live, but you should be able to listen to the onSaveEntry event, then check the same criteria that Craft uses to determine if an entry is live or not. As far as tracking if it's the first time the entry had a live status or not, it's kind of lame, but your plugin could have a Record/table that kept ...


2

I think I found the answer, correct me if I'm wrong but you can access your post data in your plugin with: craft()->request->getPost('fields') Not sure if this is the recommended way.


2

You can change the default entry status in your section settings. Example: If I would set the German toggle to disabled, all entries added to German local will be disabled by default.


2

You could hook into the entries.beforeSaveEntry event like this: craft()->on('entries.beforeSaveEntry', function (Event $e) { // Get the entry we're saving, and it's title $entry = $e->params['entry']; $title = $entry->getContent()->title; // Look for existing entries with the same title $existingEntry = craft()->...


2

From the README: If there is a validation error on the entry, then the page will be reloaded with an entry variable available to it... You can override the variable name by setting the entryVariable config setting, as follows: <?php // File: craft/config/guestentries.php return [ 'entryVariable' => 'guestEntry', ]; Once you've done that, ...


2

I'm going to go out on a limb and say you're trying to upload a file type that isn't allowed under that Asset fields "Restrict Allowed File Types?" section.


2

Steps to fix: Change the radio button default to an alternative option. Go to entry and remove the matrix block. Save entry Readd the matrix block. You should be able to correctly save the block, a long process but I couldn’t figure out what was going on.


2

This should be as simple as setting the relation field (category, asset, etc.) on the entry as an array of related element IDs before saving. $entry->categoryFieldHandle = [$categoryId1, $categoryId2]; Craft::$app->elements->saveElement($entry); This will work for all relation fields: $entry->assetFieldHandle = [$assetId1, $assetId2]; Craft::...


2

If it's only one single field and you want to bypass all Craft validations for required fields you can change the value directly in your database using Yii commands and the update function function update($table, $columns, $conditions='', $params=array()) $command = craft()->db->createCommand(); $command->update('craft_content', array( ...


2

Just so there's an answer here. OP was using Craft 2 code in a Craft 3 environment. The code should be something like this in Craft 3: $entry = new Entry(); $entry->sectionId = $yourSectionId; $entry->typeId = $yourEntryTypeId; $entry->authorId = $yourAuthorId; $entry->enabled = true; $entry->title = "Foo"; $entry->setFieldValues([ '...


2

I just figured it out. For anyone facing the same issue, here is what worked for me: $entryData = self::setupEntryData($item); $entry = new Entry($entryData); $fieldValues = [ 'blocks' => [ // Neo field handle 'new0' => [ 'modified' => 1, 'type' => 'wysiwyg', // Neo block handle 'enabled' => 1,...


2

You need to use newParentId: $navigationItem = new Entry(); $navigationItem->typeId = 4; $navigationItem->sectionId = $navigationSection->id; $navigationItem->title = $entry->title; $navigationItem->newParentId = $herbsNavigationEntry->id; $navigationItem->setFieldValue('navLink', '/tags/' . $entry->slug); if (!Craft::$app->...


1

For anyone experiencing this issue, what solved it for me was deleting the craft application files and replacing them with the ones from the same release version. It seems one of them got corrupted at some point.


Only top voted, non community-wiki answers of a minimum length are eligible