Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:43:04+00:00 2026-06-07T15:43:04+00:00

The problem is the checkboxlist selection which is a multiple select. When I remove

  • 0

The problem is the checkboxlist selection which is a multiple select. When I remove the following mailer code from the controller, the form is emailed… '{serviceItem}' => $model->selection,

In the model, the following explode and implode is used for putting the selection into the db table correctly…

public function afterFind()
{

    $this->selection=explode(',',$this->selection);

        return true;

}

/*implode your selection */
public function beforeSave()
{
    $this->selection=implode(',',$this->selection);
        return true;


}

If implode beforeSave…

[quote=”php manual”] Returns a string containing a string
representation of all the array elements in the same order, with the
glue string between each element.[/quote]

And the mailer $message = strtr returns a string from the array…

[quote=”phpmanual”]strtr – If given two arguments, the second should be an array in the
form array(‘from’ => ‘to’, …). The return value is a string where all the occurrences of
the array keys have been replaced by the corresponding values…

$message = strtr ('Submitted on: {submissionDate}
Name: {firstName} {lastName}

Service Item: {serviceItem}

Visitor Comments: {message}', array(
'{submissionDate}' => $model->date,
'{firstName}' => $model->firstName,
'{lastName}' => $model->lastName,

'{serviceItem}' => $model->selection,

'{message}' => $model->comments));

Q. Why is there an error? and…

Q. What is the solution for the $model->selections to be sent in the email?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:43:05+00:00Added an answer on June 7, 2026 at 3:43 pm

    Q. Why is there an error?

    Answer:

    First strtr() expects the array to be of the form array('stringFROM'=>'stringTO') and not array('stringFROM'=>array(...)).

    You are getting the second format(and hence the error) because $model->selection is an array, since you have done an explode() in afterFind().

    afterFind() is called whenever you load a model with any of the find methods of CActiveRecord(i.e find(), findAll(), findByPk(), findByAttributes(), and so on), and if i am correct you are calling one of those of methods to get your current model.


    Q. What is the solution for the $model->selections to be sent in the email?

    Answer:

    In this case you can simply do an implode() again, to get a string:

    '{serviceItem}' => implode(',',$model->selection);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem! I Have the following input (rules) from a flat file (talking about numeric
Problem: I have an address field from an Access database which has been converted
Problem: Been struggling to get my code to load external shaders and it is
Problem in MATLAB Code for solving desired 'n' number of simultaneous equations of the
Problem: I'm streaming my video from a php file with stream_get_contents(); using Flowplayer as
I have a problem with Updating Form Element Look and Feel under Update Panel
I have a web based program which chooses some records from a database using
Problem Description: We have a service which has applications for main mobile OS’s. We
PROBLEM: Here's the code: import matplotlib.pyplot as plt plt.bar([1,2],[5,4]) plt.title('this is a very long
Hey there, i got this very annoying problem: I have a CheckBoxList getting items

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.