Comments (2)
So, I keep getting this TypeError: Argument 1 passed to Cake\ORM\Table::save() must implement interface Cake\Datasource\EntityInterface, null given, called in /var/www/html/muncie_events3/src/Controller/MailingListController.php on line 114
Lines 111-116 of MailingListController.php::join():
if ($this->request->is('post')) {
$mailingList = $this->MailingList->patchEntity($mailingList, $this->request->getData());
$newList = $this->__readFormData($mailingList);
if ($this->MailingList->save($newList)) {
$this->Flash->success(__('The mailing list has been saved.'));
}
And the aforementioned __readFormData function:
private function __readFormData($mailingList)
{
$newList = TableRegistry::get('MailingList');
$mailingList['email'] = strtolower(trim($mailingList['email']));
$newList->email = $mailingList['email'];
// If joining for the first time with default settings
if (isset($mailingList['settings'])) {
if ($mailingList['settings'] == 'default') {
$newList->weekly = 1;
$newList->all_categories = 1;
return;
}
}
// All event types
// If the user did not select 'all events', but has each category individually selected, set 'all_categories' to true
$all_categories_selected = ($mailingList['event_categories'] == 'all');
if (! $all_categories_selected) {
$selected_category_count = count($mailingList['selected_categories']);
$all_categories_count = $this->MailingList->Categories->getAll();
$all_categories_count = count($all_categories_count);
if ($selected_category_count == $all_categories_count) {
$all_categories_selected = true;
}
}
$newList->all_categories = $all_categories_selected;
// Custom event types
if (isset($mailingList['selected_categories'])) {
$newList->Categories = array_keys($mailingList['selected_categories']);
}
// Weekly frequency
$weekly = $mailingList['weekly'] || $mailingList['frequency'] == 'weekly';
$newList->weekly = $weekly;
// Daily frequency
$days = $this->MailingList->getDays();
$daily = $mailingList['frequency'] == 'daily';
foreach ($days as $code => $day) {
$value = $daily || $mailingList["daily_$code"];
$dailyCode = 'daily_'.$code;
$newList->$dailyCode = $value;
}
$newlist = "I'm a string. Are you gonna say I'm 'null' still?";
return $newList;
}
The operative code being...
$newlist = "I'm a string. Are you gonna say I'm 'null' still?";
return $newList;
I'm so lost. Most of the join() function is just skeleton app code.
from muncie-events3.
I see a void return in the block commented with
// If joining for the first time with default settings
from muncie-events3.
Related Issues (20)
- Remove commented-out code HOT 1
- Replace abandoned JsHelper
- Error loading more events when there are no events
- /tags/past looks up both past and future tags
- Daylight saving time offset needs calculated with time
- Refactor redundant DB calls in EventsTable::getStartEndEvents()
- Date picker visually broken
- Facebook app needs a new API secret
- Overhaul password reset process
- Remove unneeded font files
- Switchover checklist
- Use new icons
- Redundant search-by-tag prompt
- Tag suggestions
- Validate character encoding
- Mailing list overhaul
- Overhaul front-end dependency management
- Title correction-suggester
- Add meta pagination tags
- Feature: Venue managers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from muncie-events3.