There Are Option to Choose Upload Image to dataBase/Or Select Image Form DataBase in edtior?

There Are Option to Choose Upload Image to dataBase/Or Select Image Form DataBase in edtior?

OrTurjamenOrTurjamen Posts: 17Questions: 2Answers: 0
edited August 2019 in Free community support

i now can only upload a new image to database and to my folder, if i want to have an option to select:
upload new image or select image(and show all the images in Images table and select one of them ) how can i do this?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Answer ✓

    Hi,

    That's not a feature of the Editor upload field type at the moment I'm afraid. The closest to that would be to show a select list of the current images (or radio list or whatever) and let the user select from them, or do an upload. If one is selected and a file uploaded, then either fail it in validation or accept one over the other.

    Allan

  • OrTurjamenOrTurjamen Posts: 17Questions: 2Answers: 0

    hey Allan, if i have two database, how can i show information and select data for a field in one table from another database table? its can be done?

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Do you mean a join like this?

    Allan

  • OrTurjamenOrTurjamen Posts: 17Questions: 2Answers: 0

    i mean that i want to get table2 data form other database
    and show in option select field in table1 that from other database
    this example will maybe let you understand better
    Field::inst( 'db1.table1.field1' ),
    Field::inst( 'db2.table1.field1 )

  • OrTurjamenOrTurjamen Posts: 17Questions: 2Answers: 0

    another question, i search post for my problem and get this answer that you wrote to other user
    "The difference is that the join example doesn't insert into the joined table - only the host table (users in that example). The host table references the join.

    Editor does have the ability to insert into the joined table, but only after the row in the main table has been created or updated. Correct me if I am wrong please, but it sounds like you need to insert into your joined table and then reference that from the main table. It is that first part that Editor doesn't currently support.

    Allan"

    its still cannot be done with the editor?

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    its still cannot be done with the editor?

    That is still the case, yes.

    i mean that i want to get table2 data form other database
    and show in option select field in table1 that from other database
    this example will maybe let you understand better

    That's not something we've tested I'm afraid. However, if you consistently use the database.table.column naming style, I think it should work on MySQL (assuming that is your db of choice).

    Allan

  • OrTurjamenOrTurjamen Posts: 17Questions: 2Answers: 0

    ok thanks allan, i try to override the create method of the editor, i used ajax and turn to other url that create the fields in tables like i want, but what i need to return to this ajax call?, because all the time when i click create i get this error?

    this is my controller in server:

        public void CreateProvider(string data)
        {
            Model.JsonModel log = JsonConvert.DeserializeObject<Model.JsonModel>(data);
            using (var db = new Pegasus_OperationEntities())
            {
                BankAccountInformation a = new BankAccountInformation()
                {
                    Bank_Name = log.bankAccountInformation.Bank_Name,
                    Bank_Account = log.bankAccountInformation.Bank_AccountNumber,
                    Bank_AccountNumber = log.bankAccountInformation.Bank_AccountNumber,
                    Bank_IBAN_Number = log.bankAccountInformation.Bank_IBAN_Number,
                    Bank_SwiftNumber = log.bankAccountInformation.Bank_SwiftNumber,
                    Account_Currency = 1,
                    Phone_id = 1,
                    Address_id = 1
                };
                db.BankAccountInformations.Add(a);
                db.SaveChanges();
                var id = a.Bank_id;
                Provider provider = new Provider()
                {
                    BankAccount_Id = id,
                    Pegasus_Rate = log.provider.Pegasus_Rate,
                    OfficialMarketingImages_Id = log.provider.OfficialMarketingImages_Id,
                    Images_Id = log.provider.Images_Id,
                    ProviderType = log.provider.ProviderType
    
    
    
                };
                db.Providers.Add(provider);
                db.SaveChanges();
    
            }
    
        }
    

    (```)

    and this is my create ajax call:

    editor.on('preSubmit', function (e, data, action) {
        // CREATE A RECORD
        if (action == "create") {
            console.log(JSON.stringify(data.data[0]));
            $.ajax({
                type: 'POST',
                url: '@Url.Action("CreateProvider", "Provider")',
                data: { data: JSON.stringify(data.data[0]) }
            })
    
        }
    });
    

    (```)

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    but what i need to return to this ajax call?

    The server to client JSON format is documented here. Happy to answer any questions you have about it.

    Allan

  • OrTurjamenOrTurjamen Posts: 17Questions: 2Answers: 0

    Hey Allan, i would like to get an example for this if you can, i didnt understand how to do this from the documents!

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    This tech note details how you can see what the server is responding with.

    Allan

  • OrTurjamenOrTurjamen Posts: 17Questions: 2Answers: 0

    Hey Allan, i have a field in database called phone, now this phone value is generated from select list of (telephone) area code and text field of the phone number
    how can i can make it work with the editor?

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    So to confirm, you have the generated phone number, the area code list and also the local number all stored in the db? If so and the generated number never gets user input, its just created from the two other fields use a set formatter.

    Allan

This discussion has been closed.