Tuesday, 7 May 2013

Using the Xataface Tagger Widget for n:m relationships

The Xataface tagger widget allows you to add and remove records from a many-to-many relationship with a simple "Tag" interface.  This widget is meant to be used with a transient field (similar to the grid widget) so that users can manipulate the records in the relationship directly on the edit/new record form.

The user is able to type into a text field free form, and is assisted by auto-complete suggestions.  If they select one of the auto-complete suggestions, then they will be adding a link to an existing record.  If they don't choose one of the suggestions, they will be creating a new record in the related table and adding it to the relationship.

Since a single string isn't sufficient (in most cases) to create a new record (e.g. which field should the string be saved in?), you may need to implement that fieldname__addTag() method in the table delegate class to help guide how a tag should be added.

After the tag has been created, the user can double-click the tag to open the record's edit form and make further modifications.

Prerequisites

Installation

  1. Create a directory named "modules" inside your application's folder, if it doesn't already exist.  (e.g. /path/to/my/app/modules).
    $ cd /path/to/my/app
    $ mkdir modules
  2. Change directories to the modules directory that you just created:
    $ cd modules
  3. Check out the latest source of the tagger module from the SVN trunk:
    $ svn co http://weblite.ca/svn/dataface/modules/tagger/trunk tagger
    When you are done you should have the tagger source in the directory modules/tagger.  Ensure that you have modules/tagger/tagger.php, etc....  If not, you need to move it or rename it so that the path is correct.
  4. Add a [_modules] section to your application's conf.ini file, if it doesn't already exist.
  5. Add a line in the [_modules] section of your conf.ini file as follows:
    modules_tagger=modules/tagger/tagger.php 

Configuring a Relationship to use the Tagger Widget

Now that the tagger module is installed, we can set up our n:m relationships to be editable via a tagger widget on the edit form of the parent record.
For example, suppose we have a database with a "cities" table and a "articles" table, where cities can be associated with multiple articles and vice-versa.  I.e. There is an n:m relationship between cities and articles.
The cities relationship is defined in the articles table relationships.ini file as follows:

[cities]
    cities.id = articlecity.city_id
    articlecity.article_id = "$id"

You can see that this is a n:m relationship (among other things) because it makes use of a join table named articlecity to join them together.

Steps to Set up Tagger Widget on Cities relationship:

  1. Add a transient field to the articles table's fields.ini file as follows:
    [cities]
        widget:type=tagger
        relationship=cities
        transient=1
        tagger_label=name
    

    This says that we are creating a transient field (i.e. a field that doesn't really exist in the database, but should appear on the edit and new record forms) named "cities" using the "tagger" widget.  The relationship directive sets the widget to work on the "cities" relationship.  The tagger_label directive specifies which field from the "cities" table should be used as the text that is displayed in each tag.
  2. Load the "New Article" form in your browser to make sure that the tagger field shows up.  If you receive errors, you should check your PHP error log to find out what the error is.  If it worked it will look almost like a normal text field:
    The "Cities" field rendered with the tagger widget.
    When you start typing in the field, it will give you auto-complete suggestions as follows:
    Auto-complete in tagger widget.  If it finds any matching records in the related table, it will show them here.

  3. Implement the cities__addTag() method in the articles delegate class.  At this point (before implementing cities__addTag()), you should be able to add existing cities as tags without error.  But if you try to enter a new city, you'll receive a little error indicator because it wasn't able to add the city to the cities table.  This is because the cities table has other NOT NULL fields that need to be filled in, other than the city name.  E.g. it needs a province or state.
    The cities__addTag() method.  Our method looks like:

    function cities__addTag(Dataface_Record $record, $value){
        $city = new Dataface_Record('cities', array());
        $city->setValues(array(
            'prov_state_id' => DEFAULT_PROV_ID,
            'name' => $value,
            'url' => strtolower($value)
        ));
        return $city;
    }
    

    This method takes the "article" record as the first parameter, and the string value of the tag to add as the 2nd parameter.  In this case, we are creating a new Dataface_Record for the cities table with the name specified by $value, and a default province ID.
  4. Test out adding a new tag.   You can do this by clicking on "New Article", then start to type in the "Cities" field.
  5. You should also be able to double-click the tag to reveal the edit form for the city:

Video Tutorial

21 comments:

  1. Replies
    1. EFFECTIVE AND POWERFUL LOVE SPELL CASTER AND LOTTERY SPELL 2019 GBOJIESPIRITUALTEMPLE@GMAIL. COM OR WHATSAPP HIM :+2349066410185
      Hi i am from USA I have just experience the wonders of Dr. gbojie love spell, that have been spread on the internet and worldwide, How he marvelously helped people all over the world to restored back their marriage life and get back lost lovers, and also help to win lottery. I contacted him after going through so many testimonies from different people how he help to bring back ex lover back, i told him about my husband that abandoned me about 8 months ago, and left home with all i had.. Dr GBOJIE only told me to smile and have a rest of mind he will handle all in just 24 hours, After the second day my husband called me, i was just so shocked, i pick the call and couldn't believe my ears, he was really begging me to forgive him and making promises on phone.. He came back home and also got me a new car just for him to proof his love for me. i was so happy and called Dr Gbojie and thanked him, he only told me to share the good news all over the world .. Well if you need an effective and real spell caster contact Dr gbojie Via email: gbojiespiritualtemple@gmail.com, gbojiespiritualtemple@yahoo.com or Call or WhatsApp: +2349066410185 website : http://gbojiespiritualtemple.website2.me/

      Delete
  2. An unbelievable blog. This blog will indisputably be definitely recommended to my friends as well.understanding men

    ReplyDelete
  3. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. The Psystrology Method

    ReplyDelete
  4. Modular Kitchens have changed the idea of kitchen these days because it has provided household women with a comfortable yet an elegant place through which they can spend their quality time and space. https://adamfantacy.tumblr.com/

    ReplyDelete
  5. I got this web page from my pal who shared with me on the topic of this site and at the moment this time I am visiting this website and reading very informative articles or reviews at this place. My Blog https://hollzone.tumblr.com/

    ReplyDelete
  6. Hi, I think your blog might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, excellent blog! My Blog http://www.freewebsite-service.com/moviemania/

    ReplyDelete
  7. How do you do? We just love the nice web site thanks and please stay at that My Blog http://cinemaverite.beepworld.pl/

    ReplyDelete
  8. If you have actually possessed sights of future occasions, either of something taking place in the upcoming hour or even three times off right now, you have spiritual capacities. My Blog http://www.homedatingnetwork.com/member/blog_post_view.php?postId=282363

    ReplyDelete
  9. Your blog is very useful for me,like you post.Thanks for sharing.
    gclub casino
    goldenslot
    Gclub จีคลับ

    ReplyDelete
  10. If you want your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you have to watch this video
    right away...

    (VIDEO) Why your ex will NEVER come back...

    ReplyDelete
  11. Thank you for helping people get the information they need. Great stuff as usual. Keep up the great work!!!
    Transfer 

    ReplyDelete
  12. EFFECTIVE AND POWERFUL LOVE SPELL CASTER AND LOTTERY SPELL 2019 GBOJIESPIRITUALTEMPLE@GMAIL. COM OR WHATSAPP HIM :+2349066410185
    Hi i am from USA I have just experience the wonders of Dr. gbojie love spell, that have been spread on the internet and worldwide, How he marvelously helped people all over the world to restored back their marriage life and get back lost lovers, and also help to win lottery. I contacted him after going through so many testimonies from different people how he help to bring back ex lover back, i told him about my husband that abandoned me about 8 months ago, and left home with all i had.. Dr GBOJIE only told me to smile and have a rest of mind he will handle all in just 24 hours, After the second day my husband called me, i was just so shocked, i pick the call and couldn't believe my ears, he was really begging me to forgive him and making promises on phone.. He came back home and also got me a new car just for him to proof his love for me. i was so happy and called Dr Gbojie and thanked him, he only told me to share the good news all over the world .. Well if you need an effective and real spell caster contact Dr gbojie Via email: gbojiespiritualtemple@gmail.com, gbojiespiritualtemple@yahoo.com or Call or WhatsApp: +2349066410185 website : http://gbojiespiritualtemple.website2.me/

    ReplyDelete
  13. Amazing Love Spell To Get Back With your Partner and Fix Your Broken Relationship

    My husband broke up with me 3 months ago, and forced me to sign the divorce papers, and i was completely heartbroken. And I could not get back into any shape emotionally. I Thank God for this astonishing and brilliant spell caster that came to my rescue. Wow! This spell caster has helped me so much. Dr Isikolo guaranteed me an urgent 24 hours spell casting, of which i accepted it. Shockingly! this month on the 5TH OF September 2019, my husband called me back with lots of apologies after 48 hours which he assured me, and he did everything possible to withdraw the divorce papers which was previously ongoing with the power of this miracle working spell caster.Some people testified that he brought their Ex lover back, some testified that he restores womb, cure cancer, herpes simplex virus and other sickness, Thank you so so so much Lord for your powerful spells. expressions are not sufficient to say thank you. Email Dr Isikolo Now for Urgent love Spell isikolosolutionhome@gmail.com You can also Whatsapp him on +2348133261196.

    ReplyDelete
  14. Contact Dr Isikolo at isikolosolutionhome@gmail if you want to get your Husband, Wife, Boyfriend and Girlfriend back now and regain your happiness.
    I am really pleased with this service Dr Isikolo render to me. I am one of those people who said, I will never call a psychic or a magician or whatever” to help me with my problems least of all my love problems, but I reached the point where I knew I needed some guidance, and I’m so glad I found this man called Dr Isikolo I never in a million years would have thought I’d be writing a letter like this, but when I nearly lost Andre in one of our stupid, fights (he broke up with me), I thought I had lost everything. i cry all day and think that he will never come back to me again.I read a testimony by a man called Taylor Borg about him saying that how Dr Isikolo helps him to get back is ex wife within 48 hours. I quickly email him. He did a (Lover spell) for me. 48 hours later, my (ex boyfriend) came to me and apologized for the wrongs he did and promise never to do it again. Ever since then, everything has returned back to normal and our love is now stronger that he can't do without being with me. I and my boyfriend are living together happily again. Dr Isikolo is the best online spell caster that is powerful and genuine. And when I was at my most desperate, he didn’t take advantage of me. You performed a very good service for a person in true need. I don’t know how you did it, or how this magic works, but all I know is, IT WORKS!! Andrew and i are happily back together, and I’ll always be grateful to Dr Isikolo email him isikolosolutionhome@gmail.com You can also Whatsapp him on +2348133261196.

    ReplyDelete
  15. This is the website I read about Doctor Ilekhojie and contacted him to help me get my ex boyfriend back to marry me during the month of May this year and I have come back here to post about him. Doctor Ilekhojie will help you solve your problem no matter what you are going through. Posting about a spell caster is very strange to me because I never believed i will be able to say that I was helped by a spell caster in bringing my ex boyfriend back to me after 3 years of no contact. I read about Doctor Ilekhojie from other websites and contacted him to help me and in less than 48 hours my ex boyfriend called me and I was happy that he wants to get back to me. We met on Friday and he proposed to me,... It was the most beautiful ring. Please everyone out here, Contact Doctor Ilekhojie to solve your problem for you and make you happy with your relationship that is hurting you. Love is the best feeling ever experienced. Email him at gethelp05@gmail.com or directly on whats App him +2348147400259

    ReplyDelete
  16. hello everyone here i am Jack Mark a medical doctor from United Kingdom , i want to share a great testimony of how Dr AKIOYA herbal mixture cream saves me from shame and disgrace, my penis size was a big problem to me as the size was really so embarrassing and discouraging, a 39 year old full grown man like me having 4 inches penis and to worsen it i don't last in sex i cant even last two minutes it was really a thing of shame my wife was really tired of me because my sex life was very poor , she never enjoyed sex, i was always thinking and searching for solutions everywhere until last two months when i saw a testimony of how Dr AKIOYA herbal mixture cream have been helping people from the globe,i saw one MR KENNETH BERTNEY testifying of how Dr AKIOYA helped him enlarge his penis size so i decided to give him a try ,i visited his website link https://drakioyaherbalhome.blogspot.com/ we talked and he gave me steps to follow which i did and to my greatest surprise in less than two weeks of taking the herbal mixture cream my penis grow to 8 inches i couldn't believe my eyes and as i speak now my penis is now 10.5 inches long and i was amazed when my wife said i satisfy her so well now all thanks to Dr AKIOYA herbal mixture cream,i will forever be grateful To him i also learnt that Dr AKIOYA also have the herbal cure to problems like

    PENIS ENLARGEMENT
    ERECTILE DYSFUNCTION
    DIABETES type 1 and type 2
    HERPES GENITAL WART
    LOW SPERM COUNT
    WEAK ERECTION
    BREAST ENLARGEMENT
    PROSTRATE CANCER
    HIV/AIDS
    SPELL OF ALL KINDS LIKE EX BACK,CANCEL DIVORCE,BREAK UP SPELL ,PREGNANCY SPELL,PROMOTION SPELL,JOB SPELL
    ALS
    HPV 123
    PILE
    ASTHMA
    HEART FAILURE
    PREMATURE EJACULATION
    HEPATITIS A,B,C AND MANY MORE
    so if you you are suffering from any of this problems please do not hesitate to contact him now email drakioya17spellhome@gmail.com website http://drakioyaherbalcenter.home.blog
    https://drakioyaherbalhome.blogspot.com/ you can call him or Whatsapp Dr AKIOYA via whatsapp +2348105257464 thanks

    ReplyDelete
  17. Please visit (http://dradodalovetemple.com)
    i am here to give testimony on how this powerful spell caster called Dr Adoda helped me to fix my relationship. i was heartbroken when my fiancee told me he is no longer interested in marrying me because he was having an affair with the other woman where he work. I cried and sobbed every day, until it got so bad that I reached out to the Internet for help, that was when i read a review about the great work of Dr Adoda, then i contacted him for help to get my lover back, he helped me cast a powerful (reconciliation love spell) and to my greatest surprise after 48 hours of doing the love spell my Fiancee came back on his knees begging me to forgive him We are now happily married and all thanks goes to Dr Adoda Wonders for helping me save my relationship you can contact Dr Adoda through his email address: adodalovespelltemple440@gmail.com or WHATSAPP him on +2348112825421

    ReplyDelete
  18. Please visit (http://dradodalovetemple.com)
    i am here to give testimony on how this powerful spell caster called Dr Adoda helped me to fix my relationship. i was heartbroken when my fiancee told me he is no longer interested in marrying me because he was having an affair with the other woman where he work. I cried and sobbed every day, until it got so bad that I reached out to the Internet for help, that was when i read a review about the great work of Dr Adoda, then i contacted him for help to get my lover back, he helped me cast a powerful (reconciliation love spell) and to my greatest surprise after 48 hours of doing the love spell my Fiancee came back on his knees begging me to forgive him We are now happily married and all thanks goes to Dr Adoda Wonders for helping me save my relationship you can contact Dr Adoda through his email address: adodalovespelltemple440@gmail.com or WHATSAPP him on +2348112825421

    ReplyDelete
  19. If you’ve ever experienced the pain of an emotionally dead relationship or if you’ve ever had a man suddenly pull away and shut you out...

    Then what you’re about to find out will completely change the way men treat you and even how YOU experience relationships.

    Because at the end of the day, men secretly want just one thing.

    And once you understand this one crucial craving that men have…

    It will be plain as day to you why it’s the #1 reason men pull away => when it’s missing from a relationship <=

    In fact, this one secret male obsession is the biggest key to being truly irresistible to a man... in a way that goes far beyond physical attraction.

    And when you know it, you’ll never struggle to keep a man interested or connected on a deep emotional level the way most women do.

    Thousands of women who discovered this one male desire have used it to turn hopeless situations into the life fulfilling relationships they always dreamed of.

    The kind of loving companionship and exciting romance that you deserve.

    If you want to uncover this secret male desire and find out exactly how you can use it to bring you and your man closer together than ever before…

    Then click the link below and watch the free version while it’s still up:

    ==>Next time your man shuts you out do this

    You’ll be glad you did.

    ReplyDelete